From 157055c03ba861d9b5a5153b19aa21039c1d08b1 Mon Sep 17 00:00:00 2001 From: joyceerhl Date: Sun, 10 Jan 2021 00:14:29 -0800 Subject: [PATCH 001/164] Original files --- src/common/public/Terminal.ts | 339 +++++++++ typings/xterm-core.d.ts | 1207 +++++++++++++++++++++++++++++++++ 2 files changed, 1546 insertions(+) create mode 100644 src/common/public/Terminal.ts create mode 100644 typings/xterm-core.d.ts diff --git a/src/common/public/Terminal.ts b/src/common/public/Terminal.ts new file mode 100644 index 000000000..70247f88e --- /dev/null +++ b/src/common/public/Terminal.ts @@ -0,0 +1,339 @@ +/** + * Copyright (c) 2018 The xterm.js authors. All rights reserved. + * @license MIT + */ + +import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi, IParser, IFunctionIdentifier, ILinkProvider, IUnicodeHandling, IUnicodeVersionProvider, FontWeight } from 'xterm'; +import { ITerminal } from 'browser/Types'; +import { IBufferLine, ICellData } from 'common/Types'; +import { IBuffer, IBufferSet } from 'common/buffer/Types'; +import { CellData } from 'common/buffer/CellData'; +import { Terminal as TerminalCore } from '../Terminal'; +import * as Strings from '../LocalizableStrings'; +import { IEvent, EventEmitter } from 'common/EventEmitter'; +import { AddonManager } from './AddonManager'; +import { IParams } from 'common/parser/Types'; +import { BufferSet } from 'common/buffer/BufferSet'; + +export class Terminal implements ITerminalApi { + private _core: ITerminal; + private _addonManager: AddonManager; + private _parser: IParser | undefined; + private _buffer: BufferNamespaceApi | undefined; + + constructor(options?: ITerminalOptions) { + this._core = new TerminalCore(options); + this._addonManager = new AddonManager(); + } + + 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 onCursorMove(): IEvent { return this._core.onCursorMove; } + public get onLineFeed(): IEvent { return this._core.onLineFeed; } + public get onSelectionChange(): IEvent { return this._core.onSelectionChange; } + public get onData(): IEvent { return this._core.onData; } + public get onBinary(): IEvent { return this._core.onBinary; } + public get onTitleChange(): IEvent { return this._core.onTitleChange; } + public get onScroll(): IEvent { return this._core.onScroll; } + public get onKey(): IEvent<{ key: string, domEvent: KeyboardEvent }> { return this._core.onKey; } + public get onRender(): IEvent<{ start: number, end: number }> { return this._core.onRender; } + public get onResize(): IEvent<{ cols: number, rows: number }> { return this._core.onResize; } + + public get element(): HTMLElement | undefined { return this._core.element; } + 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 textarea(): HTMLTextAreaElement | undefined { return this._core.textarea; } + 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 { + this._checkProposedApi(); + return this._core.markers; + } + public blur(): void { + this._core.blur(); + } + public focus(): void { + this._core.focus(); + } + public resize(columns: number, rows: number): void { + this._verifyIntegers(columns, rows); + this._core.resize(columns, rows); + } + public open(parent: HTMLElement): void { + this._core.open(parent); + } + public attachCustomKeyEventHandler(customKeyEventHandler: (event: KeyboardEvent) => boolean): void { + this._core.attachCustomKeyEventHandler(customKeyEventHandler); + } + public registerLinkMatcher(regex: RegExp, handler: (event: MouseEvent, uri: string) => void, options?: ILinkMatcherOptions): number { + this._checkProposedApi(); + return this._core.registerLinkMatcher(regex, handler, options); + } + public deregisterLinkMatcher(matcherId: number): void { + this._checkProposedApi(); + this._core.deregisterLinkMatcher(matcherId); + } + public registerLinkProvider(linkProvider: ILinkProvider): IDisposable { + this._checkProposedApi(); + return this._core.registerLinkProvider(linkProvider); + } + public registerCharacterJoiner(handler: (text: string) => [number, number][]): number { + this._checkProposedApi(); + return this._core.registerCharacterJoiner(handler); + } + public deregisterCharacterJoiner(joinerId: number): void { + this._checkProposedApi(); + this._core.deregisterCharacterJoiner(joinerId); + } + public registerMarker(cursorYOffset: number): IMarker | undefined { + this._checkProposedApi(); + this._verifyIntegers(cursorYOffset); + return this._core.addMarker(cursorYOffset); + } + public addMarker(cursorYOffset: number): IMarker | undefined { + return this.registerMarker(cursorYOffset); + } + public hasSelection(): boolean { + return this._core.hasSelection(); + } + public select(column: number, row: number, length: number): void { + this._verifyIntegers(column, row, length); + this._core.select(column, row, length); + } + public getSelection(): string { + return this._core.getSelection(); + } + public getSelectionPosition(): ISelectionPosition | undefined { + return this._core.getSelectionPosition(); + } + public clearSelection(): void { + this._core.clearSelection(); + } + public selectAll(): void { + this._core.selectAll(); + } + public selectLines(start: number, end: number): void { + this._verifyIntegers(start, end); + this._core.selectLines(start, end); + } + 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 paste(data: string): void { + this._core.paste(data); + } + 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: 'fontWeight' | 'fontWeightBold'): FontWeight; + 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: 'theme', value: ITheme): 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 refresh(start: number, end: number): void { + this._verifyIntegers(start, end); + this._core.refresh(start, end); + } + public reset(): void { + this._core.reset(); + } + public loadAddon(addon: ITerminalAddon): void { + return this._addonManager.loadAddon(this, addon); + } + public static get strings(): ILocalizableStrings { + return Strings; + } + + 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'); + } + } + } +} + +class BufferApiView implements IBufferApi { + constructor( + private _buffer: IBuffer, + public readonly type: 'normal' | 'alternate' + ) { } + + public init(buffer: IBuffer): BufferApiView { + this._buffer = buffer; + return this; + } + + public get cursorY(): number { return this._buffer.y; } + public get cursorX(): number { return this._buffer.x; } + public get viewportY(): number { return this._buffer.ydisp; } + public get baseY(): number { return this._buffer.ybase; } + public get length(): number { return this._buffer.lines.length; } + public getLine(y: number): IBufferLineApi | undefined { + const line = this._buffer.lines.get(y); + if (!line) { + return undefined; + } + return new BufferLineApiView(line); + } + public getNullCell(): IBufferCellApi { return new CellData(); } +} + +class BufferNamespaceApi implements IBufferNamespaceApi { + private _normal: BufferApiView; + private _alternate: BufferApiView; + private _onBufferChange = new EventEmitter(); + public get onBufferChange(): IEvent { return this._onBufferChange.event; } + + constructor(private _core: ITerminal) { + this._normal = new BufferApiView(this._core.buffers.normal, 'normal'); + this._alternate = new BufferApiView(this._core.buffers.alt, 'alternate'); + this._core.buffers.onBufferActivate(() => this._onBufferChange.fire(this.active)); + } + public get active(): IBufferApi { + if (this._core.buffers.active === this._core.buffers.normal) { return this.normal; } + if (this._core.buffers.active === this._core.buffers.alt) { return this.alternate; } + throw new Error('Active buffer is neither normal nor alternate'); + } + public get normal(): IBufferApi { + return this._normal.init(this._core.buffers.normal); + } + public get alternate(): IBufferApi { + return this._alternate.init(this._core.buffers.alt); + } +} + +class BufferLineApiView implements IBufferLineApi { + constructor(private _line: IBufferLine) { } + + public get isWrapped(): boolean { return this._line.isWrapped; } + public get length(): number { return this._line.length; } + public getCell(x: number, cell?: IBufferCellApi): IBufferCellApi | undefined { + if (x < 0 || x >= this._line.length) { + return undefined; + } + + if (cell) { + this._line.loadCell(x, cell); + return cell; + } + return this._line.loadCell(x, new CellData()); + } + public translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string { + return this._line.translateToString(trimRight, startColumn, endColumn); + } +} + +class ParserApi implements IParser { + constructor(private _core: ITerminal) { } + + public registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable { + return this._core.addCsiHandler(id, (params: IParams) => callback(params.toArray())); + } + public addCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable { + return this.registerCsiHandler(id, callback); + } + public registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable { + return this._core.addDcsHandler(id, (data: string, params: IParams) => callback(data, params.toArray())); + } + public addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable { + return this.registerDcsHandler(id, callback); + } + public registerEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable { + return this._core.addEscHandler(id, handler); + } + public addEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable { + return this.registerEscHandler(id, handler); + } + public registerOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { + return this._core.addOscHandler(ident, callback); + } + public addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { + return this.registerOscHandler(ident, callback); + } +} + +class UnicodeApi implements IUnicodeHandling { + constructor(private _core: ITerminal) { } + + public register(provider: IUnicodeVersionProvider): void { + this._core.unicodeService.register(provider); + } + + public get versions(): string[] { + return this._core.unicodeService.versions; + } + + public get activeVersion(): string { + return this._core.unicodeService.activeVersion; + } + + public set activeVersion(version: string) { + this._core.unicodeService.activeVersion = version; + } +} diff --git a/typings/xterm-core.d.ts b/typings/xterm-core.d.ts new file mode 100644 index 000000000..06964ca06 --- /dev/null +++ b/typings/xterm-core.d.ts @@ -0,0 +1,1207 @@ +/** + * @license MIT + * + * This contains the type declarations for the xterm.js library. Note that + * some interfaces differ between this file and the actual implementation in + * src/, that's because this file declares the *public* API which is intended + * to be stable and consumed by external programs. + */ + +declare module 'xterm-core' { + /** + * A string representing log level. + */ + export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off'; + + /** + * An object containing start up options for the terminal. + */ + export interface ITerminalOptions { + /** + * Whether to allow the use of proposed API. When false, any usage of APIs + * marked as experimental/proposed will throw an error. This defaults to + * true currently, but will change to false in v5.0. + */ + allowProposedApi?: boolean; + + /** + * Whether background should support non-opaque color. It must be set before + * executing the `Terminal.open()` method and can't be changed later without + * executing it again. Note that enabling this can negatively impact + * performance. + */ + allowTransparency?: boolean; + + /** + * If enabled, alt + click will move the prompt cursor to position + * underneath the mouse. The default is true. + */ + altClickMovesCursor?: boolean; + + /** + * A data uri of the sound to use for the bell when `bellStyle = 'sound'`. + */ + bellSound?: string; + + /** + * The type of the bell notification the terminal will use. + */ + bellStyle?: 'none' | 'sound'; + + /** + * When enabled the cursor will be set to the beginning of the next line + * with every new line. This is equivalent to sending '\r\n' for each '\n'. + * Normally the termios settings of the underlying PTY deals with the + * translation of '\n' to '\r\n' and this setting should not be used. If you + * deal with data from a non-PTY related source, this settings might be + * useful. + */ + convertEol?: boolean; + + /** + * The number of columns in the terminal. + */ + cols?: number; + + /** + * Whether the cursor blinks. + */ + cursorBlink?: boolean; + + /** + * The style of the cursor. + */ + cursorStyle?: 'block' | 'underline' | 'bar'; + + /** + * The width of the cursor in CSS pixels when `cursorStyle` is set to 'bar'. + */ + cursorWidth?: number; + + /** + * Whether input should be disabled. + */ + disableStdin?: boolean; + + /** + * Whether to draw bold text in bright colors. The default is true. + */ + drawBoldTextInBrightColors?: boolean; + + /** + * The modifier key hold to multiply scroll speed. + */ + fastScrollModifier?: 'alt' | 'ctrl' | 'shift' | undefined; + + /** + * The spacing in whole pixels between characters. + */ + letterSpacing?: number; + + /** + * The line height used to render text. + */ + lineHeight?: number; + + /** + * The duration in milliseconds before link tooltip events fire when + * hovering on a link. + * @deprecated This will be removed when the link matcher API is removed. + */ + linkTooltipHoverDuration?: number; + + /** + * What log level to use, this will log for all levels below and including + * what is set: + * + * 1. debug + * 2. info (default) + * 3. warn + * 4. error + * 5. off + */ + logLevel?: LogLevel; + + /** + * Whether to treat option as the meta key. + */ + macOptionIsMeta?: boolean; + + /** + * Whether holding a modifier key will force normal selection behavior, + * regardless of whether the terminal is in mouse events mode. This will + * also prevent mouse events from being emitted by the terminal. For + * example, this allows you to use xterm.js' regular selection inside tmux + * with mouse mode enabled. + */ + macOptionClickForcesSelection?: boolean; + + /** + * The minimum contrast ratio for text in the terminal, setting this will + * change the foreground color dynamically depending on whether the contrast + * ratio is met. Example values: + * + * - 1: The default, do nothing. + * - 4.5: Minimum for WCAG AA compliance. + * - 7: Minimum for WCAG AAA compliance. + * - 21: White on black or black on white. + */ + minimumContrastRatio?: number; + + /** + * Whether to select the word under the cursor on right click, this is + * standard behavior in a lot of macOS applications. + */ + rightClickSelectsWord?: boolean; + + /** + * The number of rows in the terminal. + */ + rows?: number; + + /** + * Whether screen reader support is enabled. When on this will expose + * supporting elements in the DOM to support NVDA on Windows and VoiceOver + * on macOS. + */ + screenReaderMode?: boolean; + + /** + * The amount of scrollback in the terminal. Scrollback is the amount of + * rows that are retained when lines are scrolled beyond the initial + * viewport. + */ + scrollback?: number; + + /** + * The scrolling speed multiplier used for adjusting normal scrolling speed. + */ + scrollSensitivity?: number; + + /** + * The size of tab stops in the terminal. + */ + tabStopWidth?: number; + + /** + * The color theme of the terminal. + */ + theme?: ITheme; + + /** + * Whether "Windows mode" is enabled. Because Windows backends winpty and + * conpty operate by doing line wrapping on their side, xterm.js does not + * have access to wrapped lines. When Windows mode is enabled the following + * changes will be in effect: + * + * - Reflow is disabled. + * - Lines are assumed to be wrapped if the last character of the line is + * not whitespace. + */ + windowsMode?: boolean; + + /** + * A string containing all characters that are considered word separated by the + * double click to select work logic. + */ + wordSeparator?: string; + + /** + * Enable various window manipulation and report features. + * All features are disabled by default for security reasons. + */ + windowOptions?: IWindowOptions; + } + + /** + * Contains colors to theme the terminal with. + */ + export interface ITheme { + /** The default foreground color */ + foreground?: string; + /** The default background color */ + background?: string; + /** The cursor color */ + cursor?: string; + /** The accent color of the cursor (fg color for a block cursor) */ + cursorAccent?: string; + /** The selection background color (can be transparent) */ + selection?: string; + /** ANSI black (eg. `\x1b[30m`) */ + black?: string; + /** ANSI red (eg. `\x1b[31m`) */ + red?: string; + /** ANSI green (eg. `\x1b[32m`) */ + green?: string; + /** ANSI yellow (eg. `\x1b[33m`) */ + yellow?: string; + /** ANSI blue (eg. `\x1b[34m`) */ + blue?: string; + /** ANSI magenta (eg. `\x1b[35m`) */ + magenta?: string; + /** ANSI cyan (eg. `\x1b[36m`) */ + cyan?: string; + /** ANSI white (eg. `\x1b[37m`) */ + white?: string; + /** ANSI bright black (eg. `\x1b[1;30m`) */ + brightBlack?: string; + /** ANSI bright red (eg. `\x1b[1;31m`) */ + brightRed?: string; + /** ANSI bright green (eg. `\x1b[1;32m`) */ + brightGreen?: string; + /** ANSI bright yellow (eg. `\x1b[1;33m`) */ + brightYellow?: string; + /** ANSI bright blue (eg. `\x1b[1;34m`) */ + brightBlue?: string; + /** ANSI bright magenta (eg. `\x1b[1;35m`) */ + brightMagenta?: string; + /** ANSI bright cyan (eg. `\x1b[1;36m`) */ + brightCyan?: string; + /** ANSI bright white (eg. `\x1b[1;37m`) */ + brightWhite?: string; + } + + /** + * An object that can be disposed via a dispose function. + */ + export interface IDisposable { + dispose(): void; + } + + /** + * An event that can be listened to. + * @returns an `IDisposable` to stop listening. + */ + export interface IEvent { + (listener: (arg1: T, arg2: U) => any): IDisposable; + } + + /** + * Represents a specific line in the terminal that is tracked when scrollback + * is trimmed and lines are added or removed. This is a single line that may + * be part of a larger wrapped line. + */ + export interface IMarker extends IDisposable { + /** + * A unique identifier for this marker. + */ + readonly id: number; + + /** + * Whether this marker is disposed. + */ + readonly isDisposed: boolean; + + /** + * The actual line index in the buffer at this point in time. This is set to + * -1 if the marker has been disposed. + */ + readonly line: number; + + /** + * Event listener to get notified when the marker gets disposed. Automatic disposal + * might happen for a marker, that got invalidated by scrolling out or removal of + * a line from the buffer. + */ + onDispose: IEvent; + } + + /** + * The set of localizable strings. + */ + export interface ILocalizableStrings { + /** + * The aria label for the underlying input textarea for the terminal. + */ + promptLabel: string; + + /** + * Announcement for when line reading is suppressed due to too many lines + * being printed to the terminal when `screenReaderMode` is enabled. + */ + tooMuchOutput: string; + } + + /** + * Enable various window manipulation and report features (CSI Ps ; Ps ; Ps t). + * + * Most settings have no default implementation, as they heavily rely on + * the embedding environment. + * + * To implement a feature, create a custom CSI hook like this: + * ```ts + * term.parser.addCsiHandler({final: 't'}, params => { + * const ps = params[0]; + * switch (ps) { + * case XY: + * ... // your implementation for option XY + * return true; // signal Ps=XY was handled + * } + * return false; // any Ps that was not handled + * }); + * ``` + * + * Note on security: + * Most features are meant to deal with some information of the host machine + * where the terminal runs on. This is seen as a security risk possibly leaking + * sensitive data of the host to the program in the terminal. Therefore all options + * (even those without a default implementation) are guarded by the boolean flag + * and disabled by default. + */ + export interface IWindowOptions { + /** + * Ps=1 De-iconify window. + * No default implementation. + */ + restoreWin?: boolean; + /** + * Ps=2 Iconify window. + * No default implementation. + */ + minimizeWin?: boolean; + /** + * Ps=3 ; x ; y + * Move window to [x, y]. + * No default implementation. + */ + setWinPosition?: boolean; + /** + * Ps = 4 ; height ; width + * Resize the window to given `height` and `width` in pixels. + * Omitted parameters should reuse the current height or width. + * Zero parameters should use the display's height or width. + * No default implementation. + */ + setWinSizePixels?: boolean; + /** + * Ps=5 Raise the window to the front of the stacking order. + * No default implementation. + */ + raiseWin?: boolean; + /** + * Ps=6 Lower the xterm window to the bottom of the stacking order. + * No default implementation. + */ + lowerWin?: boolean; + /** Ps=7 Refresh the window. */ + refreshWin?: boolean; + /** + * Ps = 8 ; height ; width + * Resize the text area to given height and width in characters. + * Omitted parameters should reuse the current height or width. + * Zero parameters use the display's height or width. + * No default implementation. + */ + setWinSizeChars?: boolean; + /** + * Ps=9 ; 0 Restore maximized window. + * Ps=9 ; 1 Maximize window (i.e., resize to screen size). + * Ps=9 ; 2 Maximize window vertically. + * Ps=9 ; 3 Maximize window horizontally. + * No default implementation. + */ + maximizeWin?: boolean; + /** + * Ps=10 ; 0 Undo full-screen mode. + * Ps=10 ; 1 Change to full-screen. + * Ps=10 ; 2 Toggle full-screen. + * No default implementation. + */ + fullscreenWin?: boolean; + /** Ps=11 Report xterm window state. + * If the xterm window is non-iconified, it returns "CSI 1 t". + * If the xterm window is iconified, it returns "CSI 2 t". + * No default implementation. + */ + getWinState?: boolean; + /** + * Ps=13 Report xterm window position. Result is "CSI 3 ; x ; y t". + * Ps=13 ; 2 Report xterm text-area position. Result is "CSI 3 ; x ; y t". + * No default implementation. + */ + getWinPosition?: boolean; + /** + * Ps=14 Report xterm text area size in pixels. Result is "CSI 4 ; height ; width t". + * Ps=14 ; 2 Report xterm window size in pixels. Result is "CSI 4 ; height ; width t". + * Has a default implementation. + */ + getWinSizePixels?: boolean; + /** + * Ps=15 Report size of the screen in pixels. Result is "CSI 5 ; height ; width t". + * No default implementation. + */ + getScreenSizePixels?: boolean; + /** + * Ps=16 Report xterm character cell size in pixels. Result is "CSI 6 ; height ; width t". + * Has a default implementation. + */ + getCellSizePixels?: boolean; + /** + * Ps=18 Report the size of the text area in characters. Result is "CSI 8 ; height ; width t". + * Has a default implementation. + */ + getWinSizeChars?: boolean; + /** + * Ps=19 Report the size of the screen in characters. Result is "CSI 9 ; height ; width t". + * No default implementation. + */ + getScreenSizeChars?: boolean; + /** + * Ps=20 Report xterm window's icon label. Result is "OSC L label ST". + * No default implementation. + */ + getIconTitle?: boolean; + /** + * Ps=21 Report xterm window's title. Result is "OSC l label ST". + * No default implementation. + */ + getWinTitle?: boolean; + /** + * Ps=22 ; 0 Save xterm icon and window title on stack. + * Ps=22 ; 1 Save xterm icon title on stack. + * Ps=22 ; 2 Save xterm window title on stack. + * All variants have a default implementation. + */ + pushTitle?: boolean; + /** + * Ps=23 ; 0 Restore xterm icon and window title from stack. + * Ps=23 ; 1 Restore xterm icon title from stack. + * Ps=23 ; 2 Restore xterm window title from stack. + * All variants have a default implementation. + */ + popTitle?: boolean; + /** + * Ps>=24 Resize to Ps lines (DECSLPP). + * DECSLPP is not implemented. This settings is also used to + * enable / disable DECCOLM (earlier variant of DECSLPP). + */ + setWinLines?: boolean; + } + + /** + * The class that represents an xterm.js terminal. + */ + export class Terminal implements IDisposable { + /** + * The number of rows in the terminal's viewport. Use + * `ITerminalOptions.rows` to set this in the constructor and + * `Terminal.resize` for when the terminal exists. + */ + readonly rows: number; + + /** + * The number of columns in the terminal's viewport. Use + * `ITerminalOptions.cols` to set this in the constructor and + * `Terminal.resize` for when the terminal exists. + */ + readonly cols: number; + + /** + * (EXPERIMENTAL) The terminal's current buffer, this might be either the + * normal buffer or the alt buffer depending on what's running in the + * terminal. + */ + readonly buffer: IBufferNamespace; + + /** + * (EXPERIMENTAL) Get all markers registered against the buffer. If the alt + * buffer is active this will always return []. + */ + readonly markers: ReadonlyArray; + + /** + * (EXPERIMENTAL) Get the parser interface to register + * custom escape sequence handlers. + */ + readonly parser: IParser; + + /** + * (EXPERIMENTAL) Get the Unicode handling interface + * to register and switch Unicode version. + */ + readonly unicode: IUnicodeHandling; + + /** + * Natural language strings that can be localized. + */ + static strings: ILocalizableStrings; + + /** + * Creates a new `Terminal` object. + * + * @param options An object containing a set of options. + */ + constructor(options?: ITerminalOptions); + + /** + * Adds an event listener for when a binary event fires. This is used to + * enable non UTF-8 conformant binary messages to be sent to the backend. + * Currently this is only used for a certain type of mouse reports that + * happen to be not UTF-8 compatible. + * The event value is a JS string, pass it to the underlying pty as + * binary data, e.g. `pty.write(Buffer.from(data, 'binary'))`. + * @returns an `IDisposable` to stop listening. + */ + onBinary: IEvent; + + /** + * Adds an event listener for the cursor moves. + * @returns an `IDisposable` to stop listening. + */ + onCursorMove: IEvent; + + /** + * Adds an event listener for when a data event fires. This happens for + * example when the user types or pastes into the terminal. The event value + * is whatever `string` results, in a typical setup, this should be passed + * on to the backing pty. + * @returns an `IDisposable` to stop listening. + */ + onData: IEvent; + + /** + * Adds an event listener for when a line feed is added. + * @returns an `IDisposable` to stop listening. + */ + onLineFeed: IEvent; + + /** + * Adds an event listener for when the terminal is resized. The event value + * contains the new size. + * @returns an `IDisposable` to stop listening. + */ + onResize: IEvent<{ cols: number, rows: number }>; + + /** + * Adds an event listener for when an OSC 0 or OSC 2 title change occurs. + * The event value is the new title. + * @returns an `IDisposable` to stop listening. + */ + onTitleChange: IEvent; + + /** + * Resizes the terminal. It's best practice to debounce calls to resize, + * this will help ensure that the pty can respond to the resize event + * before another one occurs. + * @param x The number of columns to resize to. + * @param y The number of rows to resize to. + */ + resize(columns: number, rows: number): void; + + /** + * (EXPERIMENTAL) Adds a marker to the normal buffer and returns it. If the + * alt buffer is active, undefined is returned. + * @param cursorYOffset The y position offset of the marker from the cursor. + * @returns The new marker or undefined. + */ + registerMarker(cursorYOffset: number): IMarker | undefined; + + /** + * @deprecated use `registerMarker` instead. + */ + addMarker(cursorYOffset: number): IMarker | undefined; + + /* + * Disposes of the terminal, detaching it from the DOM and removing any + * active listeners. + */ + dispose(): void; + + /** + * Clear the entire buffer, making the prompt line the new first line. + */ + clear(): void; + + /** + * Write data to the terminal. + * @param data The data to write to the terminal. This can either be raw + * bytes given as Uint8Array from the pty or a string. Raw bytes will always + * be treated as UTF-8 encoded, string data as UTF-16. + * @param callback Optional callback that fires when the data was processed + * by the parser. + */ + write(data: string | Uint8Array, callback?: () => void): void; + + /** + * Writes data to the terminal, followed by a break line character (\n). + * @param data The data to write to the terminal. This can either be raw + * bytes given as Uint8Array from the pty or a string. Raw bytes will always + * be treated as UTF-8 encoded, string data as UTF-16. + * @param callback Optional callback that fires when the data was processed + * by the parser. + */ + writeln(data: string | Uint8Array, callback?: () => void): void; + + /** + * Write UTF8 data to the terminal. + * @param data The data to write to the terminal. + * @param callback Optional callback when data was processed. + * @deprecated use `write` instead + */ + writeUtf8(data: Uint8Array, callback?: () => void): void; + + /** + * Retrieves an option's value from the terminal. + * @param key The option key. + */ + getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string; + /** + * Retrieves an option's value from the terminal. + * @param key The option key. + */ + getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell' | 'windowsMode'): boolean; + /** + * Retrieves an option's value from the terminal. + * @param key The option key. + */ + getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number; + /** + * Retrieves an option's value from the terminal. + * @param key The option key. + */ + getOption(key: string): any; + + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'fontFamily' | 'termName' | 'bellSound' | 'wordSeparator', value: string): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'fontWeight' | 'fontWeightBold', value: null | 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'logLevel', value: LogLevel): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'bellStyle', value: null | 'none' | 'visual' | 'sound' | 'both'): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'cursorStyle', value: null | 'block' | 'underline' | 'bar'): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'popOnBell' | 'rightClickSelectsWord' | 'visualBell' | 'windowsMode', value: boolean): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'theme', value: ITheme): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'cols' | 'rows', value: number): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: string, value: any): void; + + /** + * Perform a full reset (RIS, aka '\x1bc'). + */ + reset(): void; + } + + /** + * An addon that can provide additional functionality to the terminal. + */ + export interface ITerminalAddon extends IDisposable { + /** + * This is called when the addon is activated. + */ + activate(terminal: Terminal): void; + } + + /** + * An object representing a selection within the terminal. + */ + interface ISelectionPosition { + /** + * The start column of the selection. + */ + startColumn: number; + + /** + * The start row of the selection. + */ + startRow: number; + + /** + * The end column of the selection. + */ + endColumn: number; + + /** + * The end row of the selection. + */ + endRow: number; + } + + /** + * An object representing a range within the viewport of the terminal. + */ + export interface IViewportRange { + /** + * The start of the range. + */ + start: IViewportRangePosition; + + /** + * The end of the range. + */ + end: IViewportRangePosition; + } + + /** + * An object representing a cell position within the viewport of the terminal. + */ + interface IViewportRangePosition { + /** + * The x position of the cell. This is a 0-based index that refers to the + * space in between columns, not the column itself. Index 0 refers to the + * left side of the viewport, index `Terminal.cols` refers to the right side + * of the viewport. This can be thought of as how a cursor is positioned in + * a text editor. + */ + x: number; + + /** + * The y position of the cell. This is a 0-based index that refers to a + * specific row. + */ + y: number; + } + + /** + * A range within a buffer. + */ + interface IBufferRange { + /** + * The start position of the range. + */ + start: IBufferCellPosition; + + /** + * The end position of the range. + */ + end: IBufferCellPosition; + } + + /** + * A position within a buffer. + */ + interface IBufferCellPosition { + /** + * The x position within the buffer. + */ + x: number; + + /** + * The y position within the buffer. + */ + y: number; + } + + /** + * Represents a terminal buffer. + */ + interface IBuffer { + /** + * The type of the buffer. + */ + readonly type: 'normal' | 'alternate'; + + /** + * The y position of the cursor. This ranges between `0` (when the + * cursor is at baseY) and `Terminal.rows - 1` (when the cursor is on the + * last row). + */ + readonly cursorY: number; + + /** + * The x position of the cursor. This ranges between `0` (left side) and + * `Terminal.cols` (after last cell of the row). + */ + readonly cursorX: number; + + /** + * The line within the buffer where the top of the viewport is. + */ + readonly viewportY: number; + + /** + * The line within the buffer where the top of the bottom page is (when + * fully scrolled down). + */ + readonly baseY: number; + + /** + * The amount of lines in the buffer. + */ + readonly length: number; + + /** + * Gets a line from the buffer, or undefined if the line index does not + * exist. + * + * Note that the result of this function should be used immediately after + * calling as when the terminal updates it could lead to unexpected + * behavior. + * + * @param y The line index to get. + */ + getLine(y: number): IBufferLine | undefined; + + /** + * Creates an empty cell object suitable as a cell reference in + * `line.getCell(x, cell)`. Use this to avoid costly recreation of + * cell objects when dealing with tons of cells. + */ + getNullCell(): IBufferCell; + } + + /** + * Represents the terminal's set of buffers. + */ + interface IBufferNamespace { + /** + * The active buffer, this will either be the normal or alternate buffers. + */ + readonly active: IBuffer; + + /** + * The normal buffer. + */ + readonly normal: IBuffer; + + /** + * The alternate buffer, this becomes the active buffer when an application + * enters this mode via DECSET (`CSI ? 4 7 h`) + */ + readonly alternate: IBuffer; + + /** + * Adds an event listener for when the active buffer changes. + * @returns an `IDisposable` to stop listening. + */ + onBufferChange: IEvent; + } + + /** + * Represents a line in the terminal's buffer. + */ + interface IBufferLine { + /** + * Whether the line is wrapped from the previous line. + */ + readonly isWrapped: boolean; + + /** + * The length of the line, all call to getCell beyond the length will result + * in `undefined`. + */ + readonly length: number; + + /** + * Gets a cell from the line, or undefined if the line index does not exist. + * + * Note that the result of this function should be used immediately after + * calling as when the terminal updates it could lead to unexpected + * behavior. + * + * @param x The character index to get. + * @param cell Optional cell object to load data into for performance + * reasons. This is mainly useful when every cell in the buffer is being + * looped over to avoid creating new objects for every cell. + */ + getCell(x: number, cell?: IBufferCell): IBufferCell | undefined; + + /** + * Gets the line as a string. Note that this is gets only the string for the + * line, not taking isWrapped into account. + * + * @param trimRight Whether to trim any whitespace at the right of the line. + * @param startColumn The column to start from (inclusive). + * @param endColumn The column to end at (exclusive). + */ + translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string; + } + + /** + * Represents a single cell in the terminal's buffer. + */ + interface IBufferCell { + /** + * The width of the character. Some examples: + * + * - `1` for most cells. + * - `2` for wide character like CJK glyphs. + * - `0` for cells immediately following cells with a width of `2`. + */ + getWidth(): number; + + /** + * The character(s) within the cell. Examples of what this can contain: + * + * - A normal width character + * - A wide character (eg. CJK) + * - An emoji + */ + getChars(): string; + + /** + * Gets the UTF32 codepoint of single characters, if content is a combined + * string it returns the codepoint of the last character in the string. + */ + getCode(): number; + + /** + * Gets the number representation of the foreground color mode, this can be + * used to perform quick comparisons of 2 cells to see if they're the same. + * Use `isFgRGB`, `isFgPalette` and `isFgDefault` to check what color mode + * a cell is. + */ + getFgColorMode(): number; + + /** + * Gets the number representation of the background color mode, this can be + * used to perform quick comparisons of 2 cells to see if they're the same. + * Use `isBgRGB`, `isBgPalette` and `isBgDefault` to check what color mode + * a cell is. + */ + getBgColorMode(): number; + + /** + * Gets a cell's foreground color number, this differs depending on what the + * color mode of the cell is: + * + * - Default: This should be 0, representing the default foreground color + * (CSI 39 m). + * - Palette: This is a number from 0 to 255 of ANSI colors (CSI 3(0-7) m, + * CSI 9(0-7) m, CSI 38 ; 5 ; 0-255 m). + * - RGB: A hex value representing a 'true color': 0xRRGGBB. + * (CSI 3 8 ; 2 ; Pi ; Pr ; Pg ; Pb) + */ + getFgColor(): number; + + /** + * Gets a cell's background color number, this differs depending on what the + * color mode of the cell is: + * + * - Default: This should be 0, representing the default background color + * (CSI 49 m). + * - Palette: This is a number from 0 to 255 of ANSI colors + * (CSI 4(0-7) m, CSI 10(0-7) m, CSI 48 ; 5 ; 0-255 m). + * - RGB: A hex value representing a 'true color': 0xRRGGBB + * (CSI 4 8 ; 2 ; Pi ; Pr ; Pg ; Pb) + */ + getBgColor(): number; + + /** Whether the cell has the bold attribute (CSI 1 m). */ + isBold(): number; + /** Whether the cell has the inverse attribute (CSI 3 m). */ + isItalic(): number; + /** Whether the cell has the inverse attribute (CSI 2 m). */ + isDim(): number; + /** Whether the cell has the underline attribute (CSI 4 m). */ + isUnderline(): number; + /** Whether the cell has the inverse attribute (CSI 5 m). */ + isBlink(): number; + /** Whether the cell has the inverse attribute (CSI 7 m). */ + isInverse(): number; + /** Whether the cell has the inverse attribute (CSI 8 m). */ + isInvisible(): number; + + /** Whether the cell is using the RGB foreground color mode. */ + isFgRGB(): boolean; + /** Whether the cell is using the RGB background color mode. */ + isBgRGB(): boolean; + /** Whether the cell is using the palette foreground color mode. */ + isFgPalette(): boolean; + /** Whether the cell is using the palette background color mode. */ + isBgPalette(): boolean; + /** Whether the cell is using the default foreground color mode. */ + isFgDefault(): boolean; + /** Whether the cell is using the default background color mode. */ + isBgDefault(): boolean; + + /** Whether the cell has the default attribute (no color or style). */ + isAttributeDefault(): boolean; + } + + /** + * Data type to register a CSI, DCS or ESC callback in the parser + * in the form: + * ESC I..I F + * CSI Prefix P..P I..I F + * DCS Prefix P..P I..I F data_bytes ST + * + * with these rules/restrictions: + * - prefix can only be used with CSI and DCS + * - only one leading prefix byte is recognized by the parser + * before any other parameter bytes (P..P) + * - intermediate bytes are recognized up to 2 + * + * For custom sequences make sure to read ECMA-48 and the resources at + * vt100.net to not clash with existing sequences or reserved address space. + * General recommendations: + * - use private address space (see ECMA-48) + * - use max one intermediate byte (technically not limited by the spec, + * in practice there are no sequences with more than one intermediate byte, + * thus parsers might get confused with more intermediates) + * - test against other common emulators to check whether they escape/ignore + * the sequence correctly + * + * Notes: OSC command registration is handled differently (see addOscHandler) + * APC, PM or SOS is currently not supported. + */ + export interface IFunctionIdentifier { + /** + * Optional prefix byte, must be in range \x3c .. \x3f. + * Usable in CSI and DCS. + */ + prefix?: string; + /** + * Optional intermediate bytes, must be in range \x20 .. \x2f. + * Usable in CSI, DCS and ESC. + */ + intermediates?: string; + /** + * Final byte, must be in range \x40 .. \x7e for CSI and DCS, + * \x30 .. \x7e for ESC. + */ + final: string; + } + + /** + * Allows hooking into the parser for custom handling of escape sequences. + */ + export interface IParser { + /** + * Adds a handler for CSI escape sequences. + * @param id Specifies the function identifier under which the callback + * gets registered, e.g. {final: 'm'} for SGR. + * @param callback The function to handle the sequence. The callback is + * called with the numerical params. If the sequence has subparams the + * array will contain subarrays with their numercial values. + * Return true if the sequence was handled; false if we should try + * a previous handler (set by addCsiHandler or setCsiHandler). + * The most recently added handler is tried first. + * @return An IDisposable you can call to remove this handler. + */ + registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable; + + /** + * Adds a handler for DCS escape sequences. + * @param id Specifies the function identifier under which the callback + * gets registered, e.g. {intermediates: '$' final: 'q'} for DECRQSS. + * @param callback The function to handle the sequence. Note that the + * function will only be called once if the sequence finished sucessfully. + * There is currently no way to intercept smaller data chunks, data chunks + * will be stored up until the sequence is finished. Since DCS sequences + * are not limited by the amount of data this might impose a problem for + * big payloads. Currently xterm.js limits DCS payload to 10 MB + * which should give enough room for most use cases. + * The function gets the payload and numerical parameters as arguments. + * Return true if the sequence was handled; false if we should try + * a previous handler (set by addDcsHandler or setDcsHandler). + * The most recently added handler is tried first. + * @return An IDisposable you can call to remove this handler. + */ + registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable; + + /** + * Adds a handler for ESC escape sequences. + * @param id Specifies the function identifier under which the callback + * gets registered, e.g. {intermediates: '%' final: 'G'} for + * default charset selection. + * @param callback The function to handle the sequence. + * Return true if the sequence was handled; false if we should try + * a previous handler (set by addEscHandler or setEscHandler). + * The most recently added handler is tried first. + * @return An IDisposable you can call to remove this handler. + */ + registerEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable; + + /** + * Adds a handler for OSC escape sequences. + * @param ident The number (first parameter) of the sequence. + * @param callback The function to handle the sequence. Note that the + * function will only be called once if the sequence finished sucessfully. + * There is currently no way to intercept smaller data chunks, data chunks + * will be stored up until the sequence is finished. Since OSC sequences + * are not limited by the amount of data this might impose a problem for + * big payloads. Currently xterm.js limits OSC payload to 10 MB + * which should give enough room for most use cases. + * The callback is called with OSC data string. + * Return true if the sequence was handled; false if we should try + * a previous handler (set by addOscHandler or setOscHandler). + * The most recently added handler is tried first. + * @return An IDisposable you can call to remove this handler. + */ + registerOscHandler(ident: number, callback: (data: string) => boolean): IDisposable; + } + + /** + * (EXPERIMENTAL) Unicode version provider. + * Used to register custom Unicode versions with `Terminal.unicode.register`. + */ + export interface IUnicodeVersionProvider { + /** + * String indicating the Unicode version provided. + */ + readonly version: string; + + /** + * Unicode version dependent wcwidth implementation. + */ + wcwidth(codepoint: number): 0 | 1 | 2; + } + + /** + * (EXPERIMENTAL) Unicode handling interface. + */ + export interface IUnicodeHandling { + /** + * Register a custom Unicode version provider. + */ + register(provider: IUnicodeVersionProvider): void; + + /** + * Registered Unicode versions. + */ + readonly versions: ReadonlyArray; + + /** + * Getter/setter for active Unicode version. + */ + activeVersion: string; + } + } + \ No newline at end of file From 5e6e65c8da6ee21bb8c669702aa7a3f4e91a10fa Mon Sep 17 00:00:00 2001 From: joyceerhl Date: Sun, 10 Jan 2021 22:18:41 -0800 Subject: [PATCH 002/164] Get dupe of src/browser/public/Terminal compiling --- core-webpack.config.js | 41 ++++++++ package.json | 1 + src/common/public/Terminal.ts | 108 +-------------------- src/common/public/TerminalCore.ts | 155 ++++++++++++++++++++++++++++++ src/common/public/tsconfig.json | 21 ++++ src/common/public/types.ts | 31 ++++++ 6 files changed, 253 insertions(+), 104 deletions(-) create mode 100644 core-webpack.config.js create mode 100644 src/common/public/TerminalCore.ts create mode 100644 src/common/public/tsconfig.json create mode 100644 src/common/public/types.ts diff --git a/core-webpack.config.js b/core-webpack.config.js new file mode 100644 index 000000000..85c37ff12 --- /dev/null +++ b/core-webpack.config.js @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2019 The xterm.js authors. All rights reserved. + * @license MIT + */ + +const path = require('path'); + +/** + * This webpack config does a production build for xterm-core.js. It works by taking the output from tsc + * (via `yarn watch` or `yarn prebuild`) which are put into `xterm-core/` and webpacks them into a + * production mode commonjs library module in `lib/`. The aliases are used fix up the absolute paths + * output by tsc (because of `baseUrl` and `paths` in `tsconfig.json`. + */ +module.exports = { + entry: './xterm-core/common/public/Terminal.js', + devtool: 'source-map', + module: { + rules: [ + { + test: /\.js$/, + use: ["source-map-loader"], + enforce: "pre", + exclude: /node_modules/ + } + ] + }, + resolve: { + modules: ['./node_modules'], + extensions: [ '.js' ], + alias: { + common: path.resolve('./xterm-core/common') + } + }, + output: { + filename: 'xterm-core.js', + path: path.resolve('./lib'), + libraryTarget: 'commonjs' + }, + mode: 'production', + target: 'node', +}; diff --git a/package.json b/package.json index 599029314..aa6f5a1bd 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "scripts": { "prepackage": "npm run build", "package": "webpack", + "compile": "tsc -b ./src/common/public/tsconfig.json", "start": "node demo/start", "lint": "eslint -c .eslintrc.json --max-warnings 0 --ext .ts src/ addons/", "test": "npm run test-unit", diff --git a/src/common/public/Terminal.ts b/src/common/public/Terminal.ts index 70247f88e..39ad5cd44 100644 --- a/src/common/public/Terminal.ts +++ b/src/common/public/Terminal.ts @@ -3,27 +3,22 @@ * @license MIT */ -import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi, IParser, IFunctionIdentifier, ILinkProvider, IUnicodeHandling, IUnicodeVersionProvider, FontWeight } from 'xterm'; -import { ITerminal } from 'browser/Types'; +import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi, IParser, IFunctionIdentifier, IUnicodeHandling, IUnicodeVersionProvider } from 'xterm-core'; import { IBufferLine, ICellData } from 'common/Types'; -import { IBuffer, IBufferSet } from 'common/buffer/Types'; +import { IBuffer } from 'common/buffer/Types'; import { CellData } from 'common/buffer/CellData'; -import { Terminal as TerminalCore } from '../Terminal'; -import * as Strings from '../LocalizableStrings'; +import { Terminal as TerminalCore } from './TerminalCore'; import { IEvent, EventEmitter } from 'common/EventEmitter'; -import { AddonManager } from './AddonManager'; import { IParams } from 'common/parser/Types'; -import { BufferSet } from 'common/buffer/BufferSet'; +import { ITerminal } from 'common/public/types'; export class Terminal implements ITerminalApi { private _core: ITerminal; - private _addonManager: AddonManager; private _parser: IParser | undefined; private _buffer: BufferNamespaceApi | undefined; constructor(options?: ITerminalOptions) { this._core = new TerminalCore(options); - this._addonManager = new AddonManager(); } private _checkProposedApi(): void { @@ -34,16 +29,11 @@ export class Terminal implements ITerminalApi { public get onCursorMove(): IEvent { return this._core.onCursorMove; } public get onLineFeed(): IEvent { return this._core.onLineFeed; } - public get onSelectionChange(): IEvent { return this._core.onSelectionChange; } public get onData(): IEvent { return this._core.onData; } public get onBinary(): IEvent { return this._core.onBinary; } public get onTitleChange(): IEvent { return this._core.onTitleChange; } - public get onScroll(): IEvent { return this._core.onScroll; } - public get onKey(): IEvent<{ key: string, domEvent: KeyboardEvent }> { return this._core.onKey; } - public get onRender(): IEvent<{ start: number, end: number }> { return this._core.onRender; } public get onResize(): IEvent<{ cols: number, rows: number }> { return this._core.onResize; } - public get element(): HTMLElement | undefined { return this._core.element; } public get parser(): IParser { this._checkProposedApi(); if (!this._parser) { @@ -55,7 +45,6 @@ export class Terminal implements ITerminalApi { this._checkProposedApi(); return new UnicodeApi(this._core); } - public get textarea(): HTMLTextAreaElement | undefined { return this._core.textarea; } public get rows(): number { return this._core.rows; } public get cols(): number { return this._core.cols; } public get buffer(): IBufferNamespaceApi { @@ -69,42 +58,10 @@ export class Terminal implements ITerminalApi { this._checkProposedApi(); return this._core.markers; } - public blur(): void { - this._core.blur(); - } - public focus(): void { - this._core.focus(); - } public resize(columns: number, rows: number): void { this._verifyIntegers(columns, rows); this._core.resize(columns, rows); } - public open(parent: HTMLElement): void { - this._core.open(parent); - } - public attachCustomKeyEventHandler(customKeyEventHandler: (event: KeyboardEvent) => boolean): void { - this._core.attachCustomKeyEventHandler(customKeyEventHandler); - } - public registerLinkMatcher(regex: RegExp, handler: (event: MouseEvent, uri: string) => void, options?: ILinkMatcherOptions): number { - this._checkProposedApi(); - return this._core.registerLinkMatcher(regex, handler, options); - } - public deregisterLinkMatcher(matcherId: number): void { - this._checkProposedApi(); - this._core.deregisterLinkMatcher(matcherId); - } - public registerLinkProvider(linkProvider: ILinkProvider): IDisposable { - this._checkProposedApi(); - return this._core.registerLinkProvider(linkProvider); - } - public registerCharacterJoiner(handler: (text: string) => [number, number][]): number { - this._checkProposedApi(); - return this._core.registerCharacterJoiner(handler); - } - public deregisterCharacterJoiner(joinerId: number): void { - this._checkProposedApi(); - this._core.deregisterCharacterJoiner(joinerId); - } public registerMarker(cursorYOffset: number): IMarker | undefined { this._checkProposedApi(); this._verifyIntegers(cursorYOffset); @@ -113,51 +70,9 @@ export class Terminal implements ITerminalApi { public addMarker(cursorYOffset: number): IMarker | undefined { return this.registerMarker(cursorYOffset); } - public hasSelection(): boolean { - return this._core.hasSelection(); - } - public select(column: number, row: number, length: number): void { - this._verifyIntegers(column, row, length); - this._core.select(column, row, length); - } - public getSelection(): string { - return this._core.getSelection(); - } - public getSelectionPosition(): ISelectionPosition | undefined { - return this._core.getSelectionPosition(); - } - public clearSelection(): void { - this._core.clearSelection(); - } - public selectAll(): void { - this._core.selectAll(); - } - public selectLines(start: number, end: number): void { - this._verifyIntegers(start, end); - this._core.selectLines(start, end); - } 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(); } @@ -171,13 +86,9 @@ export class Terminal implements ITerminalApi { this._core.write(data); this._core.write('\r\n', callback); } - public paste(data: string): void { - this._core.paste(data); - } 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: 'fontWeight' | 'fontWeightBold'): FontWeight; public getOption(key: string): any; public getOption(key: any): any { return this._core.optionsService.getOption(key); @@ -189,25 +100,14 @@ export class Terminal implements ITerminalApi { 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: 'theme', value: ITheme): 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 refresh(start: number, end: number): void { - this._verifyIntegers(start, end); - this._core.refresh(start, end); - } public reset(): void { this._core.reset(); } - public loadAddon(addon: ITerminalAddon): void { - return this._addonManager.loadAddon(this, addon); - } - public static get strings(): ILocalizableStrings { - return Strings; - } private _verifyIntegers(...values: number[]): void { for (const value of values) { diff --git a/src/common/public/TerminalCore.ts b/src/common/public/TerminalCore.ts new file mode 100644 index 000000000..2aae1ee29 --- /dev/null +++ b/src/common/public/TerminalCore.ts @@ -0,0 +1,155 @@ +/** + * 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 { ICoreTerminal, IDisposable, IMarker, ITerminalOptions } from 'common/Types'; +import { EventEmitter, IEvent, forwardEvent } from 'common/EventEmitter'; +import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; +import { IBuffer, IBufferSet } from 'common/buffer/Types'; +import { CoreTerminal } from 'common/CoreTerminal'; +import { ITerminalOptions as IInitializedTerminalOptions } from 'common/services/Services'; +import { IFunctionIdentifier, IParams } from 'common/parser/Types'; + +export class Terminal extends CoreTerminal { + // TODO: We should remove options once components adopt optionsService + public get options(): IInitializedTerminalOptions { return this.optionsService.options; } + + + private _onCursorMove = new EventEmitter(); + public get onCursorMove(): IEvent { return this._onCursorMove.event; } + private _onTitleChange = new EventEmitter(); + public get onTitleChange(): IEvent { return this._onTitleChange.event; } + + private _onA11yCharEmitter = new EventEmitter(); + public get onA11yChar(): IEvent { return this._onA11yCharEmitter.event; } + private _onA11yTabEmitter = new EventEmitter(); + public get onA11yTab(): IEvent { 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.onRequestReset(() => this.reset())); + this.register(this._inputHandler.onRequestScroll((eraseAttr, isWrapped) => this.scroll(eraseAttr, isWrapped || undefined))); + 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; + } + + 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); + } + + /** + * 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(this.buffer.ydisp); + } + + /** + * 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/src/common/public/tsconfig.json b/src/common/public/tsconfig.json new file mode 100644 index 000000000..6e14ddf70 --- /dev/null +++ b/src/common/public/tsconfig.json @@ -0,0 +1,21 @@ +{ + "extends": "../../tsconfig-library-base", + "compilerOptions": { + "lib": [ + "es2015", + "es2016.Array.Include" + ], + "outDir": "../../../xterm-core", // Temporary outdir to avoid collisions with 'xterm' + "types": [ + "../../../node_modules/@types/mocha", + "../../../node_modules/@types/node" + ], + "baseUrl": "../../", + "extendedDiagnostics": true + }, + "include": [ + "../**/*", + "../../../typings/xterm-core.d.ts", + "../../../typings/xterm.d.ts", // common/Types.d.ts imports from 'xterm' + ], +} diff --git a/src/common/public/types.ts b/src/common/public/types.ts new file mode 100644 index 000000000..1c20bd6dd --- /dev/null +++ b/src/common/public/types.ts @@ -0,0 +1,31 @@ +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; + onData: IEvent; + onBinary: IEvent; + onLineFeed: IEvent; + onResize: IEvent<{ cols: number, rows: number }>; + onTitleChange: IEvent; + 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; +} \ No newline at end of file From 2f88498ad5cb74756204f9a2f441b05136833d68 Mon Sep 17 00:00:00 2001 From: joyceerhl Date: Sun, 10 Jan 2021 22:32:36 -0800 Subject: [PATCH 003/164] Add index.js used to test xterm-core --- node-test/README.md | 10 ++++++++++ node-test/index.js | 12 ++++++++++++ node-test/package.json | 11 +++++++++++ 3 files changed, 33 insertions(+) create mode 100644 node-test/README.md create mode 100644 node-test/index.js create mode 100644 node-test/package.json diff --git a/node-test/README.md b/node-test/README.md new file mode 100644 index 000000000..e4cf19b04 --- /dev/null +++ b/node-test/README.md @@ -0,0 +1,10 @@ +Cursory test that 'xterm-core' works: + +``` +# From root of this repo +npm run compile # Outputs to xterm-core +npx webpack --config core-webpack.config.js # Outputs to lib +cd node-test +npm link ../lib/ +node index.js +``` \ No newline at end of file diff --git a/node-test/index.js b/node-test/index.js new file mode 100644 index 000000000..19bff5dc4 --- /dev/null +++ b/node-test/index.js @@ -0,0 +1,12 @@ +import { createRequire } from 'module'; +const require = createRequire(import.meta.url); +const xterm = require('xterm-core'); + +console.log('Creating xterm-core terminal...'); +const terminal = new xterm.Terminal(); +console.log('Writing `ls` to terminal...') +terminal.write('ls', () => { + const bufferLine = terminal.buffer.normal.getLine(terminal.buffer.normal.cursorY); + const contents = bufferLine.translateToString(); + console.log(`Contents of terminal active buffer are: ${contents}`); // ls +}); diff --git a/node-test/package.json b/node-test/package.json new file mode 100644 index 000000000..935496233 --- /dev/null +++ b/node-test/package.json @@ -0,0 +1,11 @@ +{ + "name": "test", + "version": "1.0.0", + "description": "", + "main": "index.js", + "type": "module", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "" +} From 0f9240207d19ffb731ed810fdc9a3679eb36593b Mon Sep 17 00:00:00 2001 From: joyceerhl Date: Mon, 11 Jan 2021 20:29:15 -0800 Subject: [PATCH 004/164] Move API view classes under common/public --- src/browser/public/Terminal.ts | 132 +----------------------- src/common/public/BufferApiView.ts | 30 ++++++ src/common/public/BufferLineApiView.ts | 24 +++++ src/common/public/BufferNamespaceApi.ts | 28 +++++ src/common/public/ParserApi.ts | 32 ++++++ src/common/public/UnicodeApi.ts | 22 ++++ 6 files changed, 141 insertions(+), 127 deletions(-) create mode 100644 src/common/public/BufferApiView.ts create mode 100644 src/common/public/BufferLineApiView.ts create mode 100644 src/common/public/BufferNamespaceApi.ts create mode 100644 src/common/public/ParserApi.ts create mode 100644 src/common/public/UnicodeApi.ts diff --git a/src/browser/public/Terminal.ts b/src/browser/public/Terminal.ts index 70247f88e..21ec6948d 100644 --- a/src/browser/public/Terminal.ts +++ b/src/browser/public/Terminal.ts @@ -3,17 +3,15 @@ * @license MIT */ -import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi, IParser, IFunctionIdentifier, ILinkProvider, IUnicodeHandling, IUnicodeVersionProvider, FontWeight } from 'xterm'; +import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBufferNamespace as IBufferNamespaceApi, IParser, ILinkProvider, IUnicodeHandling, FontWeight } from 'xterm'; import { ITerminal } from 'browser/Types'; -import { IBufferLine, ICellData } from 'common/Types'; -import { IBuffer, IBufferSet } from 'common/buffer/Types'; -import { CellData } from 'common/buffer/CellData'; import { Terminal as TerminalCore } from '../Terminal'; import * as Strings from '../LocalizableStrings'; -import { IEvent, EventEmitter } from 'common/EventEmitter'; +import { IEvent } from 'common/EventEmitter'; +import { ParserApi } from 'common/public/ParserApi'; +import { UnicodeApi } from 'common/public/UnicodeApi'; import { AddonManager } from './AddonManager'; -import { IParams } from 'common/parser/Types'; -import { BufferSet } from 'common/buffer/BufferSet'; +import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi'; export class Terminal implements ITerminalApi { private _core: ITerminal; @@ -217,123 +215,3 @@ export class Terminal implements ITerminalApi { } } } - -class BufferApiView implements IBufferApi { - constructor( - private _buffer: IBuffer, - public readonly type: 'normal' | 'alternate' - ) { } - - public init(buffer: IBuffer): BufferApiView { - this._buffer = buffer; - return this; - } - - public get cursorY(): number { return this._buffer.y; } - public get cursorX(): number { return this._buffer.x; } - public get viewportY(): number { return this._buffer.ydisp; } - public get baseY(): number { return this._buffer.ybase; } - public get length(): number { return this._buffer.lines.length; } - public getLine(y: number): IBufferLineApi | undefined { - const line = this._buffer.lines.get(y); - if (!line) { - return undefined; - } - return new BufferLineApiView(line); - } - public getNullCell(): IBufferCellApi { return new CellData(); } -} - -class BufferNamespaceApi implements IBufferNamespaceApi { - private _normal: BufferApiView; - private _alternate: BufferApiView; - private _onBufferChange = new EventEmitter(); - public get onBufferChange(): IEvent { return this._onBufferChange.event; } - - constructor(private _core: ITerminal) { - this._normal = new BufferApiView(this._core.buffers.normal, 'normal'); - this._alternate = new BufferApiView(this._core.buffers.alt, 'alternate'); - this._core.buffers.onBufferActivate(() => this._onBufferChange.fire(this.active)); - } - public get active(): IBufferApi { - if (this._core.buffers.active === this._core.buffers.normal) { return this.normal; } - if (this._core.buffers.active === this._core.buffers.alt) { return this.alternate; } - throw new Error('Active buffer is neither normal nor alternate'); - } - public get normal(): IBufferApi { - return this._normal.init(this._core.buffers.normal); - } - public get alternate(): IBufferApi { - return this._alternate.init(this._core.buffers.alt); - } -} - -class BufferLineApiView implements IBufferLineApi { - constructor(private _line: IBufferLine) { } - - public get isWrapped(): boolean { return this._line.isWrapped; } - public get length(): number { return this._line.length; } - public getCell(x: number, cell?: IBufferCellApi): IBufferCellApi | undefined { - if (x < 0 || x >= this._line.length) { - return undefined; - } - - if (cell) { - this._line.loadCell(x, cell); - return cell; - } - return this._line.loadCell(x, new CellData()); - } - public translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string { - return this._line.translateToString(trimRight, startColumn, endColumn); - } -} - -class ParserApi implements IParser { - constructor(private _core: ITerminal) { } - - public registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable { - return this._core.addCsiHandler(id, (params: IParams) => callback(params.toArray())); - } - public addCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable { - return this.registerCsiHandler(id, callback); - } - public registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable { - return this._core.addDcsHandler(id, (data: string, params: IParams) => callback(data, params.toArray())); - } - public addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable { - return this.registerDcsHandler(id, callback); - } - public registerEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable { - return this._core.addEscHandler(id, handler); - } - public addEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable { - return this.registerEscHandler(id, handler); - } - public registerOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { - return this._core.addOscHandler(ident, callback); - } - public addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { - return this.registerOscHandler(ident, callback); - } -} - -class UnicodeApi implements IUnicodeHandling { - constructor(private _core: ITerminal) { } - - public register(provider: IUnicodeVersionProvider): void { - this._core.unicodeService.register(provider); - } - - public get versions(): string[] { - return this._core.unicodeService.versions; - } - - public get activeVersion(): string { - return this._core.unicodeService.activeVersion; - } - - public set activeVersion(version: string) { - this._core.unicodeService.activeVersion = version; - } -} diff --git a/src/common/public/BufferApiView.ts b/src/common/public/BufferApiView.ts new file mode 100644 index 000000000..f6f127447 --- /dev/null +++ b/src/common/public/BufferApiView.ts @@ -0,0 +1,30 @@ +import { IBuffer as IBufferApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi } from 'xterm'; +import { IBuffer } from 'common/buffer/Types'; +import { BufferLineApiView } from 'common/public/BufferLineApiView'; +import { CellData } from 'common/buffer/CellData'; + +export class BufferApiView implements IBufferApi { + constructor( + private _buffer: IBuffer, + public readonly type: 'normal' | 'alternate' + ) { } + + public init(buffer: IBuffer): BufferApiView { + this._buffer = buffer; + return this; + } + + public get cursorY(): number { return this._buffer.y; } + public get cursorX(): number { return this._buffer.x; } + public get viewportY(): number { return this._buffer.ydisp; } + public get baseY(): number { return this._buffer.ybase; } + public get length(): number { return this._buffer.lines.length; } + public getLine(y: number): IBufferLineApi | undefined { + const line = this._buffer.lines.get(y); + if (!line) { + return undefined; + } + return new BufferLineApiView(line); + } + public getNullCell(): IBufferCellApi { return new CellData(); } +} diff --git a/src/common/public/BufferLineApiView.ts b/src/common/public/BufferLineApiView.ts new file mode 100644 index 000000000..112d6f84d --- /dev/null +++ b/src/common/public/BufferLineApiView.ts @@ -0,0 +1,24 @@ +import { CellData } from 'common/buffer/CellData'; +import { IBufferLine, ICellData } from 'common/Types'; +import { IBufferCell as IBufferCellApi, IBufferLine as IBufferLineApi } from 'xterm'; + +export class BufferLineApiView implements IBufferLineApi { + constructor(private _line: IBufferLine) { } + + public get isWrapped(): boolean { return this._line.isWrapped; } + public get length(): number { return this._line.length; } + public getCell(x: number, cell?: IBufferCellApi): IBufferCellApi | undefined { + if (x < 0 || x >= this._line.length) { + return undefined; + } + + if (cell) { + this._line.loadCell(x, cell); + return cell; + } + return this._line.loadCell(x, new CellData()); + } + public translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string { + return this._line.translateToString(trimRight, startColumn, endColumn); + } +} diff --git a/src/common/public/BufferNamespaceApi.ts b/src/common/public/BufferNamespaceApi.ts new file mode 100644 index 000000000..8d7877007 --- /dev/null +++ b/src/common/public/BufferNamespaceApi.ts @@ -0,0 +1,28 @@ +import { IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi } from 'xterm'; +import { BufferApiView } from 'common/public/BufferApiView'; +import { IEvent, EventEmitter } from 'common/EventEmitter'; +import { ITerminal } from 'browser/Types'; + +export class BufferNamespaceApi implements IBufferNamespaceApi { + private _normal: BufferApiView; + private _alternate: BufferApiView; + private _onBufferChange = new EventEmitter(); + public get onBufferChange(): IEvent { return this._onBufferChange.event; } + + constructor(private _core: ITerminal) { + this._normal = new BufferApiView(this._core.buffers.normal, 'normal'); + this._alternate = new BufferApiView(this._core.buffers.alt, 'alternate'); + this._core.buffers.onBufferActivate(() => this._onBufferChange.fire(this.active)); + } + public get active(): IBufferApi { + if (this._core.buffers.active === this._core.buffers.normal) { return this.normal; } + if (this._core.buffers.active === this._core.buffers.alt) { return this.alternate; } + throw new Error('Active buffer is neither normal nor alternate'); + } + public get normal(): IBufferApi { + return this._normal.init(this._core.buffers.normal); + } + public get alternate(): IBufferApi { + return this._alternate.init(this._core.buffers.alt); + } +} diff --git a/src/common/public/ParserApi.ts b/src/common/public/ParserApi.ts new file mode 100644 index 000000000..350d2864f --- /dev/null +++ b/src/common/public/ParserApi.ts @@ -0,0 +1,32 @@ +import { IParams } from 'common/parser/Types'; +import { ITerminal } from 'browser/Types'; +import { IDisposable, IFunctionIdentifier, IParser } from 'xterm'; + +export class ParserApi implements IParser { + constructor(private _core: ITerminal) { } + + public registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable { + return this._core.addCsiHandler(id, (params: IParams) => callback(params.toArray())); + } + public addCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable { + return this.registerCsiHandler(id, callback); + } + public registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable { + return this._core.addDcsHandler(id, (data: string, params: IParams) => callback(data, params.toArray())); + } + public addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable { + return this.registerDcsHandler(id, callback); + } + public registerEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable { + return this._core.addEscHandler(id, handler); + } + public addEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable { + return this.registerEscHandler(id, handler); + } + public registerOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { + return this._core.addOscHandler(ident, callback); + } + public addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { + return this.registerOscHandler(ident, callback); + } +} diff --git a/src/common/public/UnicodeApi.ts b/src/common/public/UnicodeApi.ts new file mode 100644 index 000000000..1bfd7a92e --- /dev/null +++ b/src/common/public/UnicodeApi.ts @@ -0,0 +1,22 @@ +import { ITerminal } from 'browser/Types'; +import { IUnicodeHandling, IUnicodeVersionProvider } from 'xterm'; + +export class UnicodeApi implements IUnicodeHandling { + constructor(private _core: ITerminal) { } + + public register(provider: IUnicodeVersionProvider): void { + this._core.unicodeService.register(provider); + } + + public get versions(): string[] { + return this._core.unicodeService.versions; + } + + public get activeVersion(): string { + return this._core.unicodeService.activeVersion; + } + + public set activeVersion(version: string) { + this._core.unicodeService.activeVersion = version; + } +} From d19a740825449ef13560109e739e1f7de89ecdad Mon Sep 17 00:00:00 2001 From: Simon Lamon Date: Sat, 15 May 2021 17:35:23 +0200 Subject: [PATCH 005/164] Support strikethrough text style --- css/xterm.css | 4 ++++ src/browser/renderer/BaseRenderLayer.ts | 15 +++++++++++++++ src/browser/renderer/TextRenderLayer.ts | 9 +++++++-- .../renderer/dom/DomRendererRowFactory.test.ts | 10 ++++++++++ src/browser/renderer/dom/DomRendererRowFactory.ts | 5 +++++ src/common/InputHandler.test.ts | 6 ++++++ src/common/InputHandler.ts | 6 ++++++ src/common/Types.d.ts | 1 + src/common/buffer/AttributeData.ts | 15 ++++++++------- src/common/buffer/Constants.ts | 5 +++-- 10 files changed, 65 insertions(+), 11 deletions(-) diff --git a/css/xterm.css b/css/xterm.css index 831a89c67..3fab18bd4 100644 --- a/css/xterm.css +++ b/css/xterm.css @@ -168,3 +168,7 @@ .xterm-underline { text-decoration: underline; } + +.xterm-strikethrough { + text-decoration: line-through; +} diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index ef869ef3f..7986e5102 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -152,6 +152,21 @@ export abstract class BaseRenderLayer implements IRenderLayer { height * this._scaledCellHeight); } + /** + * Fills a 1px line (2px on HDPI) at the middle of the cell. This uses the + * existing fillStyle on the context. + * @param x The column to fill. + * @param y The row to fill. + */ + protected _fillMiddleLineAtCells(x: number, y: number, width: number = 1): void { + const cellOffset = Math.ceil(this._scaledCellHeight * 0.5); + this._ctx.fillRect( + x * this._scaledCellWidth, + (y + 1) * this._scaledCellHeight - cellOffset - window.devicePixelRatio, + width * this._scaledCellWidth, + window.devicePixelRatio); + } + /** * Fills a 1px line (2px on HDPI) at the bottom of the cell. This uses the * existing fillStyle on the context. diff --git a/src/browser/renderer/TextRenderLayer.ts b/src/browser/renderer/TextRenderLayer.ts index ded6c9c62..59fbb7b11 100644 --- a/src/browser/renderer/TextRenderLayer.ts +++ b/src/browser/renderer/TextRenderLayer.ts @@ -215,7 +215,7 @@ export class TextRenderLayer extends BaseRenderLayer { return; } this._drawChars(cell, x, y); - if (cell.isUnderline()) { + if (cell.isUnderline() || cell.isStrikethrough()) { this._ctx.save(); if (cell.isInverse()) { @@ -244,7 +244,12 @@ export class TextRenderLayer extends BaseRenderLayer { } } - this._fillBottomLineAtCells(x, y, cell.getWidth()); + if (cell.isStrikethrough()) { + this._fillMiddleLineAtCells(x, y, cell.getWidth()); + } + if (cell.isUnderline()) { + this._fillBottomLineAtCells(x, y, cell.getWidth()); + } this._ctx.restore(); } }); diff --git a/src/browser/renderer/dom/DomRendererRowFactory.test.ts b/src/browser/renderer/dom/DomRendererRowFactory.test.ts index 9eacb97ae..2f8d264a5 100644 --- a/src/browser/renderer/dom/DomRendererRowFactory.test.ts +++ b/src/browser/renderer/dom/DomRendererRowFactory.test.ts @@ -132,6 +132,16 @@ describe('DomRendererRowFactory', () => { ); }); + it('should add class for strikethrough', () => { + const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]); + cell.fg = DEFAULT_ATTR_DATA.fg | FgFlags.STRIKETHROUGH; + lineData.setCell(0, cell); + const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20); + assert.equal(getFragmentHtml(fragment), + 'a' + ); + }); + it('should add classes for 256 foreground colors', () => { const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]); cell.fg |= Attributes.CM_P256; diff --git a/src/browser/renderer/dom/DomRendererRowFactory.ts b/src/browser/renderer/dom/DomRendererRowFactory.ts index eb2dd1fcd..a61ebd739 100644 --- a/src/browser/renderer/dom/DomRendererRowFactory.ts +++ b/src/browser/renderer/dom/DomRendererRowFactory.ts @@ -17,6 +17,7 @@ export const BOLD_CLASS = 'xterm-bold'; export const DIM_CLASS = 'xterm-dim'; export const ITALIC_CLASS = 'xterm-italic'; export const UNDERLINE_CLASS = 'xterm-underline'; +export const STRIKETHROUGH_CLASS = 'xterm-strikethrough'; export const CURSOR_CLASS = 'xterm-cursor'; export const CURSOR_BLINK_CLASS = 'xterm-cursor-blink'; export const CURSOR_STYLE_BLOCK_CLASS = 'xterm-cursor-block'; @@ -151,6 +152,10 @@ export class DomRendererRowFactory { charElement.textContent = cell.getChars() || WHITESPACE_CELL_CHAR; } + if (cell.isStrikethrough()) { + charElement.classList.add(STRIKETHROUGH_CLASS); + } + let fg = cell.getFgColor(); let fgColorMode = cell.getFgColorMode(); let bg = cell.getBgColor(); diff --git a/src/common/InputHandler.test.ts b/src/common/InputHandler.test.ts index cb60aec3d..25b602eaa 100644 --- a/src/common/InputHandler.test.ts +++ b/src/common/InputHandler.test.ts @@ -636,6 +636,12 @@ describe('InputHandler', () => { await inputHandler.parseP('\x1b[28m'); assert.equal(!!inputHandler.curAttrData.isInvisible(), false); }); + it('strikethrough', async () => { + await inputHandler.parseP('\x1b[9m'); + assert.equal(!!inputHandler.curAttrData.isStrikethrough(), true); + await inputHandler.parseP('\x1b[29m'); + assert.equal(!!inputHandler.curAttrData.isStrikethrough(), false); + }); it('colormode palette 16', async () => { assert.equal(inputHandler.curAttrData.getFgColorMode(), 0); // DEFAULT assert.equal(inputHandler.curAttrData.getBgColorMode(), 0); // DEFAULT diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index a2b5a7829..06f4ac9f5 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -2478,6 +2478,9 @@ export class InputHandler extends Disposable implements IInputHandler { } else if (p === 8) { // invisible attr.fg |= FgFlags.INVISIBLE; + } else if (p === 9) { + // strikethrough + attr.fg |= FgFlags.STRIKETHROUGH; } else if (p === 2) { // dimmed text attr.bg |= BgFlags.DIM; @@ -2503,6 +2506,9 @@ export class InputHandler extends Disposable implements IInputHandler { } else if (p === 28) { // not invisible attr.fg &= ~FgFlags.INVISIBLE; + } else if (p === 29) { + // not strikethrough + attr.fg &= ~FgFlags.STRIKETHROUGH; } else if (p === 39) { // reset fg attr.fg &= ~(Attributes.CM_MASK | Attributes.RGB_MASK); diff --git a/src/common/Types.d.ts b/src/common/Types.d.ts index df2991956..51f7e1721 100644 --- a/src/common/Types.d.ts +++ b/src/common/Types.d.ts @@ -117,6 +117,7 @@ export interface IAttributeData { isInvisible(): number; isItalic(): number; isDim(): number; + isStrikethrough(): number; // color modes getFgColorMode(): number; diff --git a/src/common/buffer/AttributeData.ts b/src/common/buffer/AttributeData.ts index c7217a2a0..43d378eaf 100644 --- a/src/common/buffer/AttributeData.ts +++ b/src/common/buffer/AttributeData.ts @@ -33,13 +33,14 @@ export class AttributeData implements IAttributeData { public extended = new ExtendedAttrs(); // flags - public isInverse(): number { return this.fg & FgFlags.INVERSE; } - public isBold(): number { return this.fg & FgFlags.BOLD; } - public isUnderline(): number { return this.fg & FgFlags.UNDERLINE; } - public isBlink(): number { return this.fg & FgFlags.BLINK; } - public isInvisible(): number { return this.fg & FgFlags.INVISIBLE; } - public isItalic(): number { return this.bg & BgFlags.ITALIC; } - public isDim(): number { return this.bg & BgFlags.DIM; } + public isInverse(): number { return this.fg & FgFlags.INVERSE; } + public isBold(): number { return this.fg & FgFlags.BOLD; } + public isUnderline(): number { return this.fg & FgFlags.UNDERLINE; } + public isBlink(): number { return this.fg & FgFlags.BLINK; } + public isInvisible(): number { return this.fg & FgFlags.INVISIBLE; } + public isItalic(): number { return this.bg & BgFlags.ITALIC; } + public isDim(): number { return this.bg & BgFlags.DIM; } + public isStrikethrough(): number { return this.fg & FgFlags.STRIKETHROUGH; } // color modes public getFgColorMode(): number { return this.fg & Attributes.CM_MASK; } diff --git a/src/common/buffer/Constants.ts b/src/common/buffer/Constants.ts index ee86a804d..a2c1b884c 100644 --- a/src/common/buffer/Constants.ts +++ b/src/common/buffer/Constants.ts @@ -110,13 +110,14 @@ export const enum Attributes { export const enum FgFlags { /** - * bit 27..31 (32th bit unused) + * bit 27..32 */ INVERSE = 0x4000000, BOLD = 0x8000000, UNDERLINE = 0x10000000, BLINK = 0x20000000, - INVISIBLE = 0x40000000 + INVISIBLE = 0x40000000, + STRIKETHROUGH = 0x80000000, } export const enum BgFlags { From 19bd04045352e1985002a28d894ee47fb0281b19 Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Fri, 11 Jun 2021 14:18:04 -0700 Subject: [PATCH 006/164] Update xterm version to 4.13.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1b290c6e1..bab93bf4d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "xterm", "description": "Full xterm terminal, in your browser", - "version": "4.12.0", + "version": "4.13.0", "main": "lib/xterm.js", "style": "css/xterm.css", "types": "typings/xterm.d.ts", From 094bcbd81d1f080d204331088aa99f4d7173d56c Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 15 Jun 2021 04:02:35 -0700 Subject: [PATCH 007/164] v0.5.1 --- addons/xterm-addon-ligatures/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/xterm-addon-ligatures/package.json b/addons/xterm-addon-ligatures/package.json index 64d8eed7d..ecbcc0066 100644 --- a/addons/xterm-addon-ligatures/package.json +++ b/addons/xterm-addon-ligatures/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-ligatures", - "version": "0.5.0", + "version": "0.5.1", "description": "Add support for programming ligatures to xterm.js", "author": { "name": "The xterm.js authors", From c7ced8009287f6539a97b92300a9382b68abe040 Mon Sep 17 00:00:00 2001 From: Labhansh Agrawal Date: Fri, 18 Jun 2021 08:27:43 +0530 Subject: [PATCH 008/164] Fix navigator types issue --- addons/xterm-addon-ligatures/src/font.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/xterm-addon-ligatures/src/font.ts b/addons/xterm-addon-ligatures/src/font.ts index 72872a0b6..abdbbc045 100644 --- a/addons/xterm-addon-ligatures/src/font.ts +++ b/addons/xterm-addon-ligatures/src/font.ts @@ -37,7 +37,7 @@ export default async function load(fontFamily: string, cacheSize: number): Promi // Web environment that supports font access API if (typeof navigator !== 'undefined' && 'fonts' in navigator) { try { - const status = await (navigator as IFontAccessNavigator).permissions.request?.({ + const status = await (navigator as unknown as IFontAccessNavigator).permissions.request?.({ name: 'local-fonts' }); if (status && status.state !== 'granted') { @@ -53,7 +53,7 @@ export default async function load(fontFamily: string, cacheSize: number): Promi } const fonts: Record = {}; try { - const fontsIterator = await (navigator as IFontAccessNavigator).fonts.query(); + const fontsIterator = await (navigator as unknown as IFontAccessNavigator).fonts.query(); for (const metadata of fontsIterator) { if (!fonts.hasOwnProperty(metadata.family)) { fonts[metadata.family] = []; From b7e96f9e54f799a9c043cdfe51bae541b8fcac07 Mon Sep 17 00:00:00 2001 From: Puneethnaik Date: Sun, 20 Jun 2021 03:31:12 +0000 Subject: [PATCH 009/164] attach a listener to inputHandler._onScroll in CoreTerminal --- src/common/CoreTerminal.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 815326d68..e61a8e16e 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -125,6 +125,10 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { this._onScroll.fire({ position: this._bufferService.buffer.ydisp, source: ScrollSource.TERMINAL }); this._dirtyRowService.markRangeDirty(this._bufferService.buffer.scrollTop, this._bufferService.buffer.scrollBottom); })); + this.register(this._inputHandler.onScroll(event => { + this._onScroll.fire({ position: this._bufferService.buffer.ydisp, source: ScrollSource.TERMINAL }); + this._dirtyRowService.markRangeDirty(this._bufferService.buffer.scrollTop, this._bufferService.buffer.scrollBottom); + })); // Setup WriteBuffer this._writeBuffer = new WriteBuffer((data, promiseResult) => this._inputHandler.parse(data, promiseResult)); From a1f65a2f77d95fd2f604e2c488e0b7165813d18d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 9 Jul 2021 06:52:28 -0700 Subject: [PATCH 010/164] Update crossed out characters support to partial --- src/common/InputHandler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 06f4ac9f5..e7d4f130f 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -2365,7 +2365,7 @@ export class InputHandler extends Disposable implements IInputHandler { * | 6 | Rapidly blinking. | #N | * | 7 | Inverse. Flips foreground and background color. | #Y | * | 8 | Invisible (hidden). | #Y | - * | 9 | Crossed-out characters. | #N | + * | 9 | Crossed-out characters. | #P[Support in DOM and Canvas renderers, not WebGL] | * | 21 | Doubly underlined. | #P[Currently outputs a single underline.] | * | 22 | Normal (neither bold nor faint). | #Y | * | 23 | No italic. | #Y | @@ -2373,7 +2373,7 @@ export class InputHandler extends Disposable implements IInputHandler { * | 25 | Steady (not blinking). | #Y | * | 27 | Positive (not inverse). | #Y | * | 28 | Visible (not hidden). | #Y | - * | 29 | Not Crossed-out. | #N | + * | 29 | Not Crossed-out. | #Y | * | 30 | Foreground color: Black. | #Y | * | 31 | Foreground color: Red. | #Y | * | 32 | Foreground color: Green. | #Y | From fa8a4853f72d88907586e6241a2429b40ee97e73 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 9 Jul 2021 06:52:54 -0700 Subject: [PATCH 011/164] Clarify crossed out = strikethrough --- src/common/InputHandler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index e7d4f130f..30c8fbe91 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -2365,7 +2365,7 @@ export class InputHandler extends Disposable implements IInputHandler { * | 6 | Rapidly blinking. | #N | * | 7 | Inverse. Flips foreground and background color. | #Y | * | 8 | Invisible (hidden). | #Y | - * | 9 | Crossed-out characters. | #P[Support in DOM and Canvas renderers, not WebGL] | + * | 9 | Crossed-out characters (strikethrough). | #P[Support in DOM and Canvas renderers, not WebGL] | * | 21 | Doubly underlined. | #P[Currently outputs a single underline.] | * | 22 | Normal (neither bold nor faint). | #Y | * | 23 | No italic. | #Y | @@ -2373,7 +2373,7 @@ export class InputHandler extends Disposable implements IInputHandler { * | 25 | Steady (not blinking). | #Y | * | 27 | Positive (not inverse). | #Y | * | 28 | Visible (not hidden). | #Y | - * | 29 | Not Crossed-out. | #Y | + * | 29 | Not Crossed-out (strikethrough). | #Y | * | 30 | Foreground color: Black. | #Y | * | 31 | Foreground color: Red. | #Y | * | 32 | Foreground color: Green. | #Y | From d8c790cb7ae0697ca8fc3c9028399d5c4c6582a2 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 9 Jul 2021 07:05:28 -0700 Subject: [PATCH 012/164] Set underlined style support to partial Feature tracked in #2251 --- src/common/InputHandler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 0b284d8e7..d4f2159f5 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -2360,7 +2360,7 @@ export class InputHandler extends Disposable implements IInputHandler { * | 1 | Bold. (also see `options.drawBoldTextInBrightColors`) | #Y | * | 2 | Faint, decreased intensity. | #Y | * | 3 | Italic. | #Y | - * | 4 | Underlined (see below for style support). | #Y | + * | 4 | Underlined (see below for style support). | #P[Support in DOM and Canvas renderers, not WebGL] | * | 5 | Slowly blinking. | #N | * | 6 | Rapidly blinking. | #N | * | 7 | Inverse. Flips foreground and background color. | #Y | From 96dd021ca4c361a547b12901d8805a9c9c07926f Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 9 Jul 2021 07:32:25 -0700 Subject: [PATCH 013/164] Support underline in webgl renderer Fixes #2251 --- addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 5e1ad195c..fb20c1c8e 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -338,6 +338,7 @@ export class WebglCharAtlas implements IDisposable { const inverse = !!this._workAttributeData.isInverse(); const dim = !!this._workAttributeData.isDim(); const italic = !!this._workAttributeData.isItalic(); + const underline = !!this._workAttributeData.isUnderline(); let fgColor = this._workAttributeData.getFgColor(); let fgColorMode = this._workAttributeData.getFgColorMode(); let bgColor = this._workAttributeData.getBgColor(); @@ -390,6 +391,12 @@ export class WebglCharAtlas implements IDisposable { // Draw the character this._tmpCtx.fillText(chars, padding, padding + this._config.scaledCharHeight); + if (underline) { + this._tmpCtx.strokeStyle = this._tmpCtx.fillStyle; + this._tmpCtx.moveTo(0, this._config.scaledCharHeight - 1); + this._tmpCtx.lineTo(this._config.scaledCharWidth, this._config.scaledCharHeight - 1); + this._tmpCtx.stroke(); + } this._tmpCtx.restore(); // clear the background from the character to avoid issues with drawing over the previous From bc702d28ff32ad3086b18a4db75e732ae544a55d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 9 Jul 2021 07:39:19 -0700 Subject: [PATCH 014/164] Support webgl strikethrough, fix underline position Fixes #580 --- .../xterm-addon-webgl/src/atlas/WebglCharAtlas.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index fb20c1c8e..db0da6d7f 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -339,6 +339,7 @@ export class WebglCharAtlas implements IDisposable { const dim = !!this._workAttributeData.isDim(); const italic = !!this._workAttributeData.isItalic(); const underline = !!this._workAttributeData.isUnderline(); + const strikethrough = !!this._workAttributeData.isStrikethrough(); let fgColor = this._workAttributeData.getFgColor(); let fgColorMode = this._workAttributeData.getFgColorMode(); let bgColor = this._workAttributeData.getBgColor(); @@ -393,9 +394,19 @@ export class WebglCharAtlas implements IDisposable { this._tmpCtx.fillText(chars, padding, padding + this._config.scaledCharHeight); if (underline) { this._tmpCtx.strokeStyle = this._tmpCtx.fillStyle; - this._tmpCtx.moveTo(0, this._config.scaledCharHeight - 1); - this._tmpCtx.lineTo(this._config.scaledCharWidth, this._config.scaledCharHeight - 1); + this._tmpCtx.beginPath(); + this._tmpCtx.moveTo(padding, padding + this._config.scaledCharHeight - 0.5); + this._tmpCtx.lineTo(padding + this._config.scaledCharWidth, padding + this._config.scaledCharHeight - 0.5); this._tmpCtx.stroke(); + this._tmpCtx.closePath(); + } + if (strikethrough) { + this._tmpCtx.strokeStyle = this._tmpCtx.fillStyle; + this._tmpCtx.beginPath(); + this._tmpCtx.moveTo(padding, padding + Math.floor(this._config.scaledCharHeight / 2) + 0.5); + this._tmpCtx.lineTo(padding + this._config.scaledCharWidth, padding + Math.floor(this._config.scaledCharHeight / 2) + 0.5); + this._tmpCtx.stroke(); + this._tmpCtx.closePath(); } this._tmpCtx.restore(); From aad6f8147e2696c9f1bb9e6cdfae10799294052c Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 9 Jul 2021 07:44:10 -0700 Subject: [PATCH 015/164] Increase underline/strikethrough width with font size --- .../src/atlas/WebglCharAtlas.ts | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index db0da6d7f..5f729e282 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -392,22 +392,26 @@ export class WebglCharAtlas implements IDisposable { // Draw the character this._tmpCtx.fillText(chars, padding, padding + this._config.scaledCharHeight); - if (underline) { + + // Draw underline and strikethrough + if (underline || strikethrough) { + const lineWidth = Math.max(1, Math.floor(this._config.fontSize / 10)); + const yOffset = this._tmpCtx.lineWidth % 2 === 1 ? 0.5 : 0; // When the width is odd, draw at 0.5 position + this._tmpCtx.lineWidth = lineWidth; this._tmpCtx.strokeStyle = this._tmpCtx.fillStyle; this._tmpCtx.beginPath(); - this._tmpCtx.moveTo(padding, padding + this._config.scaledCharHeight - 0.5); - this._tmpCtx.lineTo(padding + this._config.scaledCharWidth, padding + this._config.scaledCharHeight - 0.5); - this._tmpCtx.stroke(); - this._tmpCtx.closePath(); - } - if (strikethrough) { - this._tmpCtx.strokeStyle = this._tmpCtx.fillStyle; - this._tmpCtx.beginPath(); - this._tmpCtx.moveTo(padding, padding + Math.floor(this._config.scaledCharHeight / 2) + 0.5); - this._tmpCtx.lineTo(padding + this._config.scaledCharWidth, padding + Math.floor(this._config.scaledCharHeight / 2) + 0.5); + if (underline) { + this._tmpCtx.moveTo(padding, padding + this._config.scaledCharHeight - yOffset); + this._tmpCtx.lineTo(padding + this._config.scaledCharWidth, padding + this._config.scaledCharHeight - yOffset); + } + if (strikethrough) { + this._tmpCtx.moveTo(padding, padding + Math.floor(this._config.scaledCharHeight / 2) - yOffset); + this._tmpCtx.lineTo(padding + this._config.scaledCharWidth, padding + Math.floor(this._config.scaledCharHeight / 2) - yOffset); + } this._tmpCtx.stroke(); this._tmpCtx.closePath(); } + this._tmpCtx.restore(); // clear the background from the character to avoid issues with drawing over the previous From 1f019093fc59bb637ac9677ad5642ecd87c1241e Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 9 Jul 2021 07:48:26 -0700 Subject: [PATCH 016/164] Update SGR support table --- src/common/InputHandler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index d4f2159f5..d4354e90a 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -2360,12 +2360,12 @@ export class InputHandler extends Disposable implements IInputHandler { * | 1 | Bold. (also see `options.drawBoldTextInBrightColors`) | #Y | * | 2 | Faint, decreased intensity. | #Y | * | 3 | Italic. | #Y | - * | 4 | Underlined (see below for style support). | #P[Support in DOM and Canvas renderers, not WebGL] | + * | 4 | Underlined (see below for style support). | #Y | * | 5 | Slowly blinking. | #N | * | 6 | Rapidly blinking. | #N | * | 7 | Inverse. Flips foreground and background color. | #Y | * | 8 | Invisible (hidden). | #Y | - * | 9 | Crossed-out characters (strikethrough). | #P[Support in DOM and Canvas renderers, not WebGL] | + * | 9 | Crossed-out characters (strikethrough). | #Y | * | 21 | Doubly underlined. | #P[Currently outputs a single underline.] | * | 22 | Normal (neither bold nor faint). | #Y | * | 23 | No italic. | #Y | From 8ec33686366ad43304d818180a7bc3dcbff4f6bf Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 9 Jul 2021 08:17:52 -0700 Subject: [PATCH 017/164] Fix underline/strikethrough on space chars --- addons/xterm-addon-webgl/src/GlyphRenderer.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/xterm-addon-webgl/src/GlyphRenderer.ts b/addons/xterm-addon-webgl/src/GlyphRenderer.ts index b09fe5404..71b3659ee 100644 --- a/addons/xterm-addon-webgl/src/GlyphRenderer.ts +++ b/addons/xterm-addon-webgl/src/GlyphRenderer.ts @@ -176,8 +176,9 @@ export class GlyphRenderer { const i = (y * terminal.cols + x) * INDICES_PER_CELL; - // Exit early if this is a null/space character - if (code === NULL_CELL_CODE || code === WHITESPACE_CELL_CODE || code === undefined/* This is used for the right side of wide chars */) { + // Exit early if this is a null character, allow space character to continue as it may have + // underline/strikethrough styles + if (code === NULL_CELL_CODE || code === undefined/* This is used for the right side of wide chars */) { fill(array, 0, i, i + INDICES_PER_CELL - 1 - CELL_POSITION_INDICES); return; } From 361998bd346a0114b182899e1b35ca53aaa18d73 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 16 Jul 2021 10:08:36 -0700 Subject: [PATCH 018/164] Fix cursor ghosting in canvas/webgl renderers Fixes #3391 --- .../xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts | 7 ++++++- src/browser/renderer/CursorRenderLayer.ts | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts b/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts index b2e834d30..6aa338283 100644 --- a/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts +++ b/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts @@ -193,7 +193,12 @@ export class CursorRenderLayer extends BaseRenderLayer { private _clearCursor(): void { if (this._state) { - this._clearCells(this._state.x, this._state.y, this._state.width, 1); + // Avoid potential rounding errors when device pixel ratio is an odd number + if (window.devicePixelRatio % 1 !== 0) { + this._clearAll(); + } else { + this._clearCells(this._state.x, this._state.y, this._state.width, 1); + } this._state = { x: 0, y: 0, diff --git a/src/browser/renderer/CursorRenderLayer.ts b/src/browser/renderer/CursorRenderLayer.ts index a78b20484..8fda0b356 100644 --- a/src/browser/renderer/CursorRenderLayer.ts +++ b/src/browser/renderer/CursorRenderLayer.ts @@ -197,7 +197,12 @@ export class CursorRenderLayer extends BaseRenderLayer { private _clearCursor(): void { if (this._state) { - this._clearCells(this._state.x, this._state.y, this._state.width, 1); + // Avoid potential rounding errors when device pixel ratio is less than 1 + if (window.devicePixelRatio < 1) { + this._clearAll(); + } else { + this._clearCells(this._state.x, this._state.y, this._state.width, 1); + } this._state = { x: 0, y: 0, From 0ceeb087e9a24da2073630dbe882dc3427d3a4a8 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 16 Jul 2021 13:25:52 -0700 Subject: [PATCH 019/164] Use less than instead of non-integer check Part of #3391 --- addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts b/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts index 6aa338283..880896e02 100644 --- a/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts +++ b/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts @@ -193,8 +193,8 @@ export class CursorRenderLayer extends BaseRenderLayer { private _clearCursor(): void { if (this._state) { - // Avoid potential rounding errors when device pixel ratio is an odd number - if (window.devicePixelRatio % 1 !== 0) { + // Avoid potential rounding errors when device pixel ratio is less than 1 + if (window.devicePixelRatio < 1) { this._clearAll(); } else { this._clearCells(this._state.x, this._state.y, this._state.width, 1); From a5c6252ff577acb6d65ffcc0a66e2fb2c177e56d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 14:36:14 -0700 Subject: [PATCH 020/164] Remove browser references from common/public --- src/common/public/BufferNamespaceApi.ts | 4 ++-- src/common/public/ParserApi.ts | 4 ++-- src/common/public/UnicodeApi.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common/public/BufferNamespaceApi.ts b/src/common/public/BufferNamespaceApi.ts index 8d7877007..7c0f22876 100644 --- a/src/common/public/BufferNamespaceApi.ts +++ b/src/common/public/BufferNamespaceApi.ts @@ -1,7 +1,7 @@ import { IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi } from 'xterm'; import { BufferApiView } from 'common/public/BufferApiView'; import { IEvent, EventEmitter } from 'common/EventEmitter'; -import { ITerminal } from 'browser/Types'; +import { CoreTerminal } from 'common/CoreTerminal'; export class BufferNamespaceApi implements IBufferNamespaceApi { private _normal: BufferApiView; @@ -9,7 +9,7 @@ export class BufferNamespaceApi implements IBufferNamespaceApi { private _onBufferChange = new EventEmitter(); public get onBufferChange(): IEvent { return this._onBufferChange.event; } - constructor(private _core: ITerminal) { + constructor(private _core: CoreTerminal) { this._normal = new BufferApiView(this._core.buffers.normal, 'normal'); this._alternate = new BufferApiView(this._core.buffers.alt, 'alternate'); this._core.buffers.onBufferActivate(() => this._onBufferChange.fire(this.active)); diff --git a/src/common/public/ParserApi.ts b/src/common/public/ParserApi.ts index f8e61de4b..ffc5a0fd5 100644 --- a/src/common/public/ParserApi.ts +++ b/src/common/public/ParserApi.ts @@ -1,9 +1,9 @@ import { IParams } from 'common/parser/Types'; -import { ITerminal } from 'browser/Types'; +import { CoreTerminal } from 'common/CoreTerminal'; import { IDisposable, IFunctionIdentifier, IParser } from 'xterm'; export class ParserApi implements IParser { - constructor(private _core: ITerminal) { } + constructor(private _core: CoreTerminal) { } public registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean | Promise): IDisposable { return this._core.registerCsiHandler(id, (params: IParams) => callback(params.toArray())); diff --git a/src/common/public/UnicodeApi.ts b/src/common/public/UnicodeApi.ts index 1bfd7a92e..141863dc2 100644 --- a/src/common/public/UnicodeApi.ts +++ b/src/common/public/UnicodeApi.ts @@ -1,8 +1,8 @@ -import { ITerminal } from 'browser/Types'; +import { CoreTerminal } from 'common/CoreTerminal'; import { IUnicodeHandling, IUnicodeVersionProvider } from 'xterm'; export class UnicodeApi implements IUnicodeHandling { - constructor(private _core: ITerminal) { } + constructor(private _core: CoreTerminal) { } public register(provider: IUnicodeVersionProvider): void { this._core.unicodeService.register(provider); From 41e4de35e9fdb363d9a22a6b0062b53b941ae370 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 14:42:11 -0700 Subject: [PATCH 021/164] common/public use ICoreTerminal instead of concrete --- src/browser/Types.d.ts | 2 -- src/common/Types.d.ts | 6 ++++++ src/common/public/BufferApiView.ts | 5 +++++ src/common/public/BufferLineApiView.ts | 5 +++++ src/common/public/BufferNamespaceApi.ts | 8 +++++++- src/common/public/ParserApi.ts | 9 +++++++-- src/common/public/UnicodeApi.ts | 9 +++++++-- 7 files changed, 37 insertions(+), 7 deletions(-) diff --git a/src/browser/Types.d.ts b/src/browser/Types.d.ts index b2ff29d75..fcae7e479 100644 --- a/src/browser/Types.d.ts +++ b/src/browser/Types.d.ts @@ -14,8 +14,6 @@ export interface ITerminal extends IPublicTerminal, ICoreTerminal { element: HTMLElement | undefined; screenElement: HTMLElement | undefined; browser: IBrowser; - buffer: IBuffer; - buffers: IBufferSet; viewport: IViewport | undefined; // TODO: We should remove options once components adopt optionsService options: ITerminalOptions; diff --git a/src/common/Types.d.ts b/src/common/Types.d.ts index 51f7e1721..950e5e57f 100644 --- a/src/common/Types.d.ts +++ b/src/common/Types.d.ts @@ -8,10 +8,16 @@ import { IEvent, IEventEmitter } from 'common/EventEmitter'; import { IDeleteEvent, IInsertEvent } from 'common/CircularList'; import { IParams } from 'common/parser/Types'; import { IOptionsService, IUnicodeService } from 'common/services/Services'; +import { IBuffer, IBufferSet } from 'common/buffer/Types'; export interface ICoreTerminal { optionsService: IOptionsService; unicodeService: IUnicodeService; + buffers: IBufferSet; + registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise): IDisposable; + registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise): IDisposable; + registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise): IDisposable; + registerOscHandler(ident: number, callback: (data: string) => boolean | Promise): IDisposable; } export interface IDisposable { diff --git a/src/common/public/BufferApiView.ts b/src/common/public/BufferApiView.ts index f6f127447..56ed01550 100644 --- a/src/common/public/BufferApiView.ts +++ b/src/common/public/BufferApiView.ts @@ -1,3 +1,8 @@ +/** + * Copyright (c) 2021 The xterm.js authors. All rights reserved. + * @license MIT + */ + import { IBuffer as IBufferApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi } from 'xterm'; import { IBuffer } from 'common/buffer/Types'; import { BufferLineApiView } from 'common/public/BufferLineApiView'; diff --git a/src/common/public/BufferLineApiView.ts b/src/common/public/BufferLineApiView.ts index 2482adb74..60375015d 100644 --- a/src/common/public/BufferLineApiView.ts +++ b/src/common/public/BufferLineApiView.ts @@ -1,3 +1,8 @@ +/** + * Copyright (c) 2021 The xterm.js authors. All rights reserved. + * @license MIT + */ + import { CellData } from 'common/buffer/CellData'; import { IBufferLine, ICellData } from 'common/Types'; import { IBufferCell as IBufferCellApi, IBufferLine as IBufferLineApi } from 'xterm'; diff --git a/src/common/public/BufferNamespaceApi.ts b/src/common/public/BufferNamespaceApi.ts index 7c0f22876..c7bee6007 100644 --- a/src/common/public/BufferNamespaceApi.ts +++ b/src/common/public/BufferNamespaceApi.ts @@ -1,7 +1,13 @@ +/** + * Copyright (c) 2021 The xterm.js authors. All rights reserved. + * @license MIT + */ + import { IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi } from 'xterm'; import { BufferApiView } from 'common/public/BufferApiView'; import { IEvent, EventEmitter } from 'common/EventEmitter'; import { CoreTerminal } from 'common/CoreTerminal'; +import { ICoreTerminal } from 'common/Types'; export class BufferNamespaceApi implements IBufferNamespaceApi { private _normal: BufferApiView; @@ -9,7 +15,7 @@ export class BufferNamespaceApi implements IBufferNamespaceApi { private _onBufferChange = new EventEmitter(); public get onBufferChange(): IEvent { return this._onBufferChange.event; } - constructor(private _core: CoreTerminal) { + constructor(private _core: ICoreTerminal) { this._normal = new BufferApiView(this._core.buffers.normal, 'normal'); this._alternate = new BufferApiView(this._core.buffers.alt, 'alternate'); this._core.buffers.onBufferActivate(() => this._onBufferChange.fire(this.active)); diff --git a/src/common/public/ParserApi.ts b/src/common/public/ParserApi.ts index ffc5a0fd5..67df4be53 100644 --- a/src/common/public/ParserApi.ts +++ b/src/common/public/ParserApi.ts @@ -1,9 +1,14 @@ +/** + * Copyright (c) 2021 The xterm.js authors. All rights reserved. + * @license MIT + */ + import { IParams } from 'common/parser/Types'; -import { CoreTerminal } from 'common/CoreTerminal'; import { IDisposable, IFunctionIdentifier, IParser } from 'xterm'; +import { ICoreTerminal } from 'common/Types'; export class ParserApi implements IParser { - constructor(private _core: CoreTerminal) { } + constructor(private _core: ICoreTerminal) { } public registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean | Promise): IDisposable { return this._core.registerCsiHandler(id, (params: IParams) => callback(params.toArray())); diff --git a/src/common/public/UnicodeApi.ts b/src/common/public/UnicodeApi.ts index 141863dc2..8a669a052 100644 --- a/src/common/public/UnicodeApi.ts +++ b/src/common/public/UnicodeApi.ts @@ -1,8 +1,13 @@ -import { CoreTerminal } from 'common/CoreTerminal'; +/** + * Copyright (c) 2021 The xterm.js authors. All rights reserved. + * @license MIT + */ + +import { ICoreTerminal } from 'common/Types'; import { IUnicodeHandling, IUnicodeVersionProvider } from 'xterm'; export class UnicodeApi implements IUnicodeHandling { - constructor(private _core: CoreTerminal) { } + constructor(private _core: ICoreTerminal) { } public register(provider: IUnicodeVersionProvider): void { this._core.unicodeService.register(provider); From cb284447c8dd58e9103d4dc4b2d99f68dbd2a76b Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 14:44:49 -0700 Subject: [PATCH 022/164] Clean up imports --- src/common/Types.d.ts | 2 +- src/common/public/BufferApiView.ts | 2 +- src/common/public/BufferNamespaceApi.ts | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/common/Types.d.ts b/src/common/Types.d.ts index 950e5e57f..36f75dd0e 100644 --- a/src/common/Types.d.ts +++ b/src/common/Types.d.ts @@ -8,7 +8,7 @@ import { IEvent, IEventEmitter } from 'common/EventEmitter'; import { IDeleteEvent, IInsertEvent } from 'common/CircularList'; import { IParams } from 'common/parser/Types'; import { IOptionsService, IUnicodeService } from 'common/services/Services'; -import { IBuffer, IBufferSet } from 'common/buffer/Types'; +import { IBufferSet } from 'common/buffer/Types'; export interface ICoreTerminal { optionsService: IOptionsService; diff --git a/src/common/public/BufferApiView.ts b/src/common/public/BufferApiView.ts index 56ed01550..ca9ef2d8f 100644 --- a/src/common/public/BufferApiView.ts +++ b/src/common/public/BufferApiView.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { IBuffer as IBufferApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi } from 'xterm'; +import { IBuffer as IBufferApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi } from 'xterm'; import { IBuffer } from 'common/buffer/Types'; import { BufferLineApiView } from 'common/public/BufferLineApiView'; import { CellData } from 'common/buffer/CellData'; diff --git a/src/common/public/BufferNamespaceApi.ts b/src/common/public/BufferNamespaceApi.ts index c7bee6007..d86f6bf5a 100644 --- a/src/common/public/BufferNamespaceApi.ts +++ b/src/common/public/BufferNamespaceApi.ts @@ -6,7 +6,6 @@ import { IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi } from 'xterm'; import { BufferApiView } from 'common/public/BufferApiView'; import { IEvent, EventEmitter } from 'common/EventEmitter'; -import { CoreTerminal } from 'common/CoreTerminal'; import { ICoreTerminal } from 'common/Types'; export class BufferNamespaceApi implements IBufferNamespaceApi { From a14bb3ead3e4fae853c813d0cf0ed778094672f1 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 14:45:39 -0700 Subject: [PATCH 023/164] Add buffer back to ITerminal --- src/browser/Types.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/browser/Types.d.ts b/src/browser/Types.d.ts index fcae7e479..c268c7bf8 100644 --- a/src/browser/Types.d.ts +++ b/src/browser/Types.d.ts @@ -14,6 +14,7 @@ export interface ITerminal extends IPublicTerminal, ICoreTerminal { element: HTMLElement | undefined; screenElement: HTMLElement | undefined; browser: IBrowser; + buffer: IBuffer; viewport: IViewport | undefined; // TODO: We should remove options once components adopt optionsService options: ITerminalOptions; From 91c7032aac38c6a3fa7d1d4a960efe5f8d7897f1 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 15:17:28 -0700 Subject: [PATCH 024/164] Use core terminal in common, remove duplicate classes --- src/common/public/Terminal.ts | 134 ++-------------------------------- 1 file changed, 6 insertions(+), 128 deletions(-) diff --git a/src/common/public/Terminal.ts b/src/common/public/Terminal.ts index 39ad5cd44..6b63ee1e7 100644 --- a/src/common/public/Terminal.ts +++ b/src/common/public/Terminal.ts @@ -3,17 +3,15 @@ * @license MIT */ -import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi, IParser, IFunctionIdentifier, IUnicodeHandling, IUnicodeVersionProvider } from 'xterm-core'; -import { IBufferLine, ICellData } from 'common/Types'; -import { IBuffer } from 'common/buffer/Types'; -import { CellData } from 'common/buffer/CellData'; +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, IParser, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-core'; import { Terminal as TerminalCore } from './TerminalCore'; -import { IEvent, EventEmitter } from 'common/EventEmitter'; -import { IParams } from 'common/parser/Types'; -import { ITerminal } from 'common/public/types'; export class Terminal implements ITerminalApi { - private _core: ITerminal; + private _core: TerminalCore; private _parser: IParser | undefined; private _buffer: BufferNamespaceApi | undefined; @@ -117,123 +115,3 @@ export class Terminal implements ITerminalApi { } } } - -class BufferApiView implements IBufferApi { - constructor( - private _buffer: IBuffer, - public readonly type: 'normal' | 'alternate' - ) { } - - public init(buffer: IBuffer): BufferApiView { - this._buffer = buffer; - return this; - } - - public get cursorY(): number { return this._buffer.y; } - public get cursorX(): number { return this._buffer.x; } - public get viewportY(): number { return this._buffer.ydisp; } - public get baseY(): number { return this._buffer.ybase; } - public get length(): number { return this._buffer.lines.length; } - public getLine(y: number): IBufferLineApi | undefined { - const line = this._buffer.lines.get(y); - if (!line) { - return undefined; - } - return new BufferLineApiView(line); - } - public getNullCell(): IBufferCellApi { return new CellData(); } -} - -class BufferNamespaceApi implements IBufferNamespaceApi { - private _normal: BufferApiView; - private _alternate: BufferApiView; - private _onBufferChange = new EventEmitter(); - public get onBufferChange(): IEvent { return this._onBufferChange.event; } - - constructor(private _core: ITerminal) { - this._normal = new BufferApiView(this._core.buffers.normal, 'normal'); - this._alternate = new BufferApiView(this._core.buffers.alt, 'alternate'); - this._core.buffers.onBufferActivate(() => this._onBufferChange.fire(this.active)); - } - public get active(): IBufferApi { - if (this._core.buffers.active === this._core.buffers.normal) { return this.normal; } - if (this._core.buffers.active === this._core.buffers.alt) { return this.alternate; } - throw new Error('Active buffer is neither normal nor alternate'); - } - public get normal(): IBufferApi { - return this._normal.init(this._core.buffers.normal); - } - public get alternate(): IBufferApi { - return this._alternate.init(this._core.buffers.alt); - } -} - -class BufferLineApiView implements IBufferLineApi { - constructor(private _line: IBufferLine) { } - - public get isWrapped(): boolean { return this._line.isWrapped; } - public get length(): number { return this._line.length; } - public getCell(x: number, cell?: IBufferCellApi): IBufferCellApi | undefined { - if (x < 0 || x >= this._line.length) { - return undefined; - } - - if (cell) { - this._line.loadCell(x, cell); - return cell; - } - return this._line.loadCell(x, new CellData()); - } - public translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string { - return this._line.translateToString(trimRight, startColumn, endColumn); - } -} - -class ParserApi implements IParser { - constructor(private _core: ITerminal) { } - - public registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable { - return this._core.addCsiHandler(id, (params: IParams) => callback(params.toArray())); - } - public addCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable { - return this.registerCsiHandler(id, callback); - } - public registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable { - return this._core.addDcsHandler(id, (data: string, params: IParams) => callback(data, params.toArray())); - } - public addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable { - return this.registerDcsHandler(id, callback); - } - public registerEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable { - return this._core.addEscHandler(id, handler); - } - public addEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable { - return this.registerEscHandler(id, handler); - } - public registerOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { - return this._core.addOscHandler(ident, callback); - } - public addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable { - return this.registerOscHandler(ident, callback); - } -} - -class UnicodeApi implements IUnicodeHandling { - constructor(private _core: ITerminal) { } - - public register(provider: IUnicodeVersionProvider): void { - this._core.unicodeService.register(provider); - } - - public get versions(): string[] { - return this._core.unicodeService.versions; - } - - public get activeVersion(): string { - return this._core.unicodeService.activeVersion; - } - - public set activeVersion(version: string) { - this._core.unicodeService.activeVersion = version; - } -} From 625e17ee1c0da9636bcd73f10da8851b90f376ae Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 15:30:55 -0700 Subject: [PATCH 025/164] Fix some errors, move TerminalCore to common/ --- .../{public/TerminalCore.ts => Terminal.ts} | 17 +++++++++++------ src/common/public/Terminal.ts | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) rename src/common/{public/TerminalCore.ts => Terminal.ts} (90%) diff --git a/src/common/public/TerminalCore.ts b/src/common/Terminal.ts similarity index 90% rename from src/common/public/TerminalCore.ts rename to src/common/Terminal.ts index 2aae1ee29..4011adb93 100644 --- a/src/common/public/TerminalCore.ts +++ b/src/common/Terminal.ts @@ -21,19 +21,20 @@ * http://linux.die.net/man/7/urxvt */ -import { ICoreTerminal, IDisposable, IMarker, ITerminalOptions } from 'common/Types'; -import { EventEmitter, IEvent, forwardEvent } from 'common/EventEmitter'; import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; -import { IBuffer, IBufferSet } from 'common/buffer/Types'; +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 { IFunctionIdentifier, IParams } from 'common/parser/Types'; +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(); + public get onBell (): IEvent { return this._onBell.event; } private _onCursorMove = new EventEmitter(); public get onCursorMove(): IEvent { return this._onCursorMove.event; } private _onTitleChange = new EventEmitter(); @@ -64,8 +65,8 @@ export class Terminal extends CoreTerminal { this._setup(); // Setup InputHandler listeners + this.register(this._inputHandler.onRequestBell(() => this.bell())); this.register(this._inputHandler.onRequestReset(() => this.reset())); - this.register(this._inputHandler.onRequestScroll((eraseAttr, isWrapped) => this.scroll(eraseAttr, isWrapped || undefined))); this.register(forwardEvent(this._inputHandler.onCursorMove, this._onCursorMove)); this.register(forwardEvent(this._inputHandler.onTitleChange, this._onTitleChange)); this.register(forwardEvent(this._inputHandler.onA11yChar, this._onA11yCharEmitter)); @@ -100,6 +101,10 @@ export class Terminal extends CoreTerminal { return this.buffer.addMarker(this.buffer.ybase + this.buffer.y + cursorYOffset); } + public bell(): void { + this._onBell.fire(); + } + /** * Resizes the terminal. * @@ -130,7 +135,7 @@ export class Terminal extends CoreTerminal { for (let i = 1; i < this.rows; i++) { this.buffer.lines.push(this.buffer.getBlankLine(DEFAULT_ATTR_DATA)); } - this._onScroll.fire(this.buffer.ydisp); + this._onScroll.fire({ position: this.buffer.ydisp, source: ScrollSource.TERMINAL }); } /** diff --git a/src/common/public/Terminal.ts b/src/common/public/Terminal.ts index 6b63ee1e7..3d195b756 100644 --- a/src/common/public/Terminal.ts +++ b/src/common/public/Terminal.ts @@ -8,7 +8,7 @@ import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi'; import { ParserApi } from 'common/public/ParserApi'; import { UnicodeApi } from 'common/public/UnicodeApi'; import { IBufferNamespace as IBufferNamespaceApi, IMarker, IParser, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-core'; -import { Terminal as TerminalCore } from './TerminalCore'; +import { Terminal as TerminalCore } from '../Terminal'; export class Terminal implements ITerminalApi { private _core: TerminalCore; From df17288c1e35983751345f8f6e05b399ba372a3a Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 15:40:13 -0700 Subject: [PATCH 026/164] Create headless project, fix compile --- .eslintrc.json | 1 + headless/headless/Terminal.d.ts | 28 + headless/headless/Terminal.d.ts.map | 1 + headless/headless/Terminal.js | 130 ++ headless/headless/Terminal.js.map | 1 + headless/headless/public/Terminal.d.ts | 48 + headless/headless/public/Terminal.d.ts.map | 1 + headless/headless/public/Terminal.js | 147 +++ headless/headless/public/Terminal.js.map | 1 + headless/headless/tsconfig.tsbuildinfo | 1120 +++++++++++++++++ headless/headless/types.d.ts | 32 + headless/headless/types.d.ts.map | 1 + headless/headless/types.js | 3 + headless/headless/types.js.map | 1 + src/common/public/tsconfig.json | 21 - src/{common => headless}/Terminal.ts | 0 .../public/types.ts => headless/Types.d.ts} | 2 +- src/{common => headless}/public/Terminal.ts | 2 +- src/headless/tsconfig.json | 27 + tsconfig.all.json | 1 + 20 files changed, 1545 insertions(+), 23 deletions(-) create mode 100644 headless/headless/Terminal.d.ts create mode 100644 headless/headless/Terminal.d.ts.map create mode 100644 headless/headless/Terminal.js create mode 100644 headless/headless/Terminal.js.map create mode 100644 headless/headless/public/Terminal.d.ts create mode 100644 headless/headless/public/Terminal.d.ts.map create mode 100644 headless/headless/public/Terminal.js create mode 100644 headless/headless/public/Terminal.js.map create mode 100644 headless/headless/tsconfig.tsbuildinfo create mode 100644 headless/headless/types.d.ts create mode 100644 headless/headless/types.d.ts.map create mode 100644 headless/headless/types.js create mode 100644 headless/headless/types.js.map delete mode 100644 src/common/public/tsconfig.json rename src/{common => headless}/Terminal.ts (100%) rename src/{common/public/types.ts => headless/Types.d.ts} (99%) rename src/{common => headless}/public/Terminal.ts (98%) create mode 100644 src/headless/tsconfig.json diff --git a/.eslintrc.json b/.eslintrc.json index 6031c195e..427c7a16d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -9,6 +9,7 @@ "project": [ "src/browser/tsconfig.json", "src/common/tsconfig.json", + "src/headless/tsconfig.json", "test/api/tsconfig.json", "test/benchmark/tsconfig.json", "addons/xterm-addon-attach/src/tsconfig.json", diff --git a/headless/headless/Terminal.d.ts b/headless/headless/Terminal.d.ts new file mode 100644 index 000000000..7ab11fc7b --- /dev/null +++ b/headless/headless/Terminal.d.ts @@ -0,0 +1,28 @@ +import { IBuffer } from 'common/buffer/Types'; +import { CoreTerminal } from 'common/CoreTerminal'; +import { IEvent } from 'common/EventEmitter'; +import { ITerminalOptions as IInitializedTerminalOptions } from 'common/services/Services'; +import { IMarker, ITerminalOptions } from 'common/Types'; +export declare class Terminal extends CoreTerminal { + get options(): IInitializedTerminalOptions; + private _onBell; + get onBell(): IEvent; + private _onCursorMove; + get onCursorMove(): IEvent; + private _onTitleChange; + get onTitleChange(): IEvent; + private _onA11yCharEmitter; + get onA11yChar(): IEvent; + private _onA11yTabEmitter; + get onA11yTab(): IEvent; + constructor(options?: ITerminalOptions); + dispose(): void; + get buffer(): IBuffer; + get markers(): IMarker[]; + addMarker(cursorYOffset: number): IMarker | undefined; + bell(): void; + resize(x: number, y: number): void; + clear(): void; + reset(): void; +} +//# sourceMappingURL=Terminal.d.ts.map \ No newline at end of file diff --git a/headless/headless/Terminal.d.ts.map b/headless/headless/Terminal.d.ts.map new file mode 100644 index 000000000..f5020f835 --- /dev/null +++ b/headless/headless/Terminal.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Terminal.d.ts","sourceRoot":"","sources":["../../src/headless/Terminal.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAA8B,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,gBAAgB,IAAI,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC3F,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAgB,MAAM,cAAc,CAAC;AAEvE,qBAAa,QAAS,SAAQ,YAAY;IAExC,IAAW,OAAO,IAAI,2BAA2B,CAAwC;IAGzF,OAAO,CAAC,OAAO,CAA6B;IAC5C,IAAW,MAAM,IAAK,MAAM,CAAC,IAAI,CAAC,CAA+B;IACjE,OAAO,CAAC,aAAa,CAA4B;IACjD,IAAW,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,CAAqC;IAC5E,OAAO,CAAC,cAAc,CAA8B;IACpD,IAAW,aAAa,IAAI,MAAM,CAAC,MAAM,CAAC,CAAsC;IAEhF,OAAO,CAAC,kBAAkB,CAA8B;IACxD,IAAW,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,CAA0C;IACjF,OAAO,CAAC,iBAAiB,CAA8B;IACvD,IAAW,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,CAAyC;gBAe7E,OAAO,GAAE,gBAAqB;IAezB,OAAO,IAAI,IAAI;IAWtB,IAAW,MAAM,IAAI,OAAO,CAE3B;IAED,IAAW,OAAO,IAAI,OAAO,EAAE,CAE9B;IAEM,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IASrD,IAAI,IAAI,IAAI;IAUZ,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAWlC,KAAK,IAAI,IAAI;IAwBb,KAAK,IAAI,IAAI;CAWrB"} \ No newline at end of file diff --git a/headless/headless/Terminal.js b/headless/headless/Terminal.js new file mode 100644 index 000000000..66f4d3646 --- /dev/null +++ b/headless/headless/Terminal.js @@ -0,0 +1,130 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Terminal = void 0; +var BufferLine_1 = require("common/buffer/BufferLine"); +var CoreTerminal_1 = require("common/CoreTerminal"); +var EventEmitter_1 = require("common/EventEmitter"); +var Terminal = (function (_super) { + __extends(Terminal, _super); + function Terminal(options) { + if (options === void 0) { options = {}; } + var _this = _super.call(this, options) || this; + _this._onBell = new EventEmitter_1.EventEmitter(); + _this._onCursorMove = new EventEmitter_1.EventEmitter(); + _this._onTitleChange = new EventEmitter_1.EventEmitter(); + _this._onA11yCharEmitter = new EventEmitter_1.EventEmitter(); + _this._onA11yTabEmitter = new EventEmitter_1.EventEmitter(); + _this._setup(); + _this.register(_this._inputHandler.onRequestBell(function () { return _this.bell(); })); + _this.register(_this._inputHandler.onRequestReset(function () { return _this.reset(); })); + _this.register(EventEmitter_1.forwardEvent(_this._inputHandler.onCursorMove, _this._onCursorMove)); + _this.register(EventEmitter_1.forwardEvent(_this._inputHandler.onTitleChange, _this._onTitleChange)); + _this.register(EventEmitter_1.forwardEvent(_this._inputHandler.onA11yChar, _this._onA11yCharEmitter)); + _this.register(EventEmitter_1.forwardEvent(_this._inputHandler.onA11yTab, _this._onA11yTabEmitter)); + return _this; + } + Object.defineProperty(Terminal.prototype, "options", { + get: function () { return this.optionsService.options; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "onBell", { + get: function () { return this._onBell.event; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "onCursorMove", { + get: function () { return this._onCursorMove.event; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "onTitleChange", { + get: function () { return this._onTitleChange.event; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "onA11yChar", { + get: function () { return this._onA11yCharEmitter.event; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "onA11yTab", { + get: function () { return this._onA11yTabEmitter.event; }, + enumerable: false, + configurable: true + }); + Terminal.prototype.dispose = function () { + if (this._isDisposed) { + return; + } + _super.prototype.dispose.call(this); + this.write = function () { }; + }; + Object.defineProperty(Terminal.prototype, "buffer", { + get: function () { + return this.buffers.active; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "markers", { + get: function () { + return this.buffer.markers; + }, + enumerable: false, + configurable: true + }); + Terminal.prototype.addMarker = function (cursorYOffset) { + if (this.buffer !== this.buffers.normal) { + return; + } + return this.buffer.addMarker(this.buffer.ybase + this.buffer.y + cursorYOffset); + }; + Terminal.prototype.bell = function () { + this._onBell.fire(); + }; + Terminal.prototype.resize = function (x, y) { + if (x === this.cols && y === this.rows) { + return; + } + _super.prototype.resize.call(this, x, y); + }; + Terminal.prototype.clear = function () { + if (this.buffer.ybase === 0 && this.buffer.y === 0) { + 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 (var i = 1; i < this.rows; i++) { + this.buffer.lines.push(this.buffer.getBlankLine(BufferLine_1.DEFAULT_ATTR_DATA)); + } + this._onScroll.fire({ position: this.buffer.ydisp, source: 0 }); + }; + Terminal.prototype.reset = function () { + this.options.rows = this.rows; + this.options.cols = this.cols; + this._setup(); + _super.prototype.reset.call(this); + }; + return Terminal; +}(CoreTerminal_1.CoreTerminal)); +exports.Terminal = Terminal; +//# sourceMappingURL=Terminal.js.map \ No newline at end of file diff --git a/headless/headless/Terminal.js.map b/headless/headless/Terminal.js.map new file mode 100644 index 000000000..ba7e26dea --- /dev/null +++ b/headless/headless/Terminal.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Terminal.js","sourceRoot":"","sources":["../../src/headless/Terminal.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAuBA,uDAA6D;AAE7D,oDAAmD;AACnD,oDAAyE;AAIzE;IAA8B,4BAAY;IA6BxC,kBACE,OAA8B;QAA9B,wBAAA,EAAA,YAA8B;QADhC,YAGE,kBAAM,OAAO,CAAC,SAWf;QAtCO,aAAO,GAAI,IAAI,2BAAY,EAAQ,CAAC;QAEpC,mBAAa,GAAG,IAAI,2BAAY,EAAQ,CAAC;QAEzC,oBAAc,GAAG,IAAI,2BAAY,EAAU,CAAC;QAG5C,wBAAkB,GAAG,IAAI,2BAAY,EAAU,CAAC;QAEhD,uBAAiB,GAAG,IAAI,2BAAY,EAAU,CAAC;QAoBrD,KAAI,CAAC,MAAM,EAAE,CAAC;QAGd,KAAI,CAAC,QAAQ,CAAC,KAAI,CAAC,aAAa,CAAC,aAAa,CAAC,cAAM,OAAA,KAAI,CAAC,IAAI,EAAE,EAAX,CAAW,CAAC,CAAC,CAAC;QACnE,KAAI,CAAC,QAAQ,CAAC,KAAI,CAAC,aAAa,CAAC,cAAc,CAAC,cAAM,OAAA,KAAI,CAAC,KAAK,EAAE,EAAZ,CAAY,CAAC,CAAC,CAAC;QACrE,KAAI,CAAC,QAAQ,CAAC,2BAAY,CAAC,KAAI,CAAC,aAAa,CAAC,YAAY,EAAE,KAAI,CAAC,aAAa,CAAC,CAAC,CAAC;QACjF,KAAI,CAAC,QAAQ,CAAC,2BAAY,CAAC,KAAI,CAAC,aAAa,CAAC,aAAa,EAAE,KAAI,CAAC,cAAc,CAAC,CAAC,CAAC;QACnF,KAAI,CAAC,QAAQ,CAAC,2BAAY,CAAC,KAAI,CAAC,aAAa,CAAC,UAAU,EAAE,KAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACpF,KAAI,CAAC,QAAQ,CAAC,2BAAY,CAAC,KAAI,CAAC,aAAa,CAAC,SAAS,EAAE,KAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;;IACpF,CAAC;IAzCD,sBAAW,6BAAO;aAAlB,cAAoD,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;;;OAAA;IAIzF,sBAAW,4BAAM;aAAjB,cAAqC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IAEjE,sBAAW,kCAAY;aAAvB,cAA0C,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IAE5E,sBAAW,mCAAa;aAAxB,cAA6C,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IAGhF,sBAAW,gCAAU;aAArB,cAA0C,OAAO,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IAEjF,sBAAW,+BAAS;aAApB,cAAyC,OAAO,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IA8BxE,0BAAO,GAAd;QACE,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,OAAO;SACR;QACD,iBAAM,OAAO,WAAE,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,cAAQ,CAAC,CAAC;IACzB,CAAC;IAKD,sBAAW,4BAAM;aAAjB;YACE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;QAC7B,CAAC;;;OAAA;IAED,sBAAW,6BAAO;aAAlB;YACE,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;QAC7B,CAAC;;;OAAA;IAEM,4BAAS,GAAhB,UAAiB,aAAqB;QAEpC,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACvC,OAAO;SACR;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC;IAClF,CAAC;IAEM,uBAAI,GAAX;QACE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;IAQM,yBAAM,GAAb,UAAc,CAAS,EAAE,CAAS;QAChC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE;YACtC,OAAO;SACR;QAED,iBAAM,MAAM,YAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACrB,CAAC;IAKM,wBAAK,GAAZ;QACE,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,EAAE;YAElD,OAAO;SACR;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC,CAAC;QACpF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;YAClC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,8BAAiB,CAAC,CAAC,CAAC;SACrE;QACD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAuB,EAAE,CAAC,CAAC;IACtF,CAAC;IAUM,wBAAK,GAAZ;QAKE,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAC9B,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAE9B,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,iBAAM,KAAK,WAAE,CAAC;IAChB,CAAC;IACH,eAAC;AAAD,CAAC,AAjID,CAA8B,2BAAY,GAiIzC;AAjIY,4BAAQ"} \ No newline at end of file diff --git a/headless/headless/public/Terminal.d.ts b/headless/headless/public/Terminal.d.ts new file mode 100644 index 000000000..669fff57f --- /dev/null +++ b/headless/headless/public/Terminal.d.ts @@ -0,0 +1,48 @@ +import { IEvent } from 'common/EventEmitter'; +import { IBufferNamespace as IBufferNamespaceApi, IMarker, IParser, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-core'; +export declare class Terminal implements ITerminalApi { + private _core; + private _parser; + private _buffer; + constructor(options?: ITerminalOptions); + private _checkProposedApi; + get onCursorMove(): IEvent; + get onLineFeed(): IEvent; + get onData(): IEvent; + get onBinary(): IEvent; + get onTitleChange(): IEvent; + get onResize(): IEvent<{ + cols: number; + rows: number; + }>; + get parser(): IParser; + get unicode(): IUnicodeHandling; + get rows(): number; + get cols(): number; + get buffer(): IBufferNamespaceApi; + get markers(): ReadonlyArray; + resize(columns: number, rows: number): void; + registerMarker(cursorYOffset: number): IMarker | undefined; + addMarker(cursorYOffset: number): IMarker | undefined; + dispose(): void; + clear(): void; + write(data: string | Uint8Array, callback?: () => void): void; + writeUtf8(data: Uint8Array, callback?: () => void): void; + writeln(data: string | Uint8Array, callback?: () => void): void; + getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string; + getOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell'): boolean; + getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number; + getOption(key: string): any; + setOption(key: 'bellSound' | 'fontFamily' | 'termName' | 'wordSeparator', value: string): void; + setOption(key: 'fontWeight' | 'fontWeightBold', value: 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void; + setOption(key: 'logLevel', value: 'debug' | 'info' | 'warn' | 'error' | 'off'): void; + setOption(key: 'bellStyle', value: 'none' | 'visual' | 'sound' | 'both'): void; + setOption(key: 'cursorStyle', value: 'block' | 'underline' | 'bar'): void; + setOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell', value: boolean): void; + setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void; + setOption(key: 'cols' | 'rows', value: number): void; + setOption(key: string, value: any): void; + reset(): void; + private _verifyIntegers; +} +//# sourceMappingURL=Terminal.d.ts.map \ No newline at end of file diff --git a/headless/headless/public/Terminal.d.ts.map b/headless/headless/public/Terminal.d.ts.map new file mode 100644 index 000000000..b8fda9330 --- /dev/null +++ b/headless/headless/public/Terminal.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Terminal.d.ts","sourceRoot":"","sources":["../../../src/headless/public/Terminal.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAI7C,OAAO,EAAE,gBAAgB,IAAI,mBAAmB,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,YAAY,CAAC;AAGrJ,qBAAa,QAAS,YAAW,YAAY;IAC3C,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,OAAO,CAAiC;gBAEpC,OAAO,CAAC,EAAE,gBAAgB;IAItC,OAAO,CAAC,iBAAiB;IAMzB,IAAW,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,CAAoC;IAC3E,IAAW,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,CAAkC;IACvE,IAAW,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,CAA8B;IACjE,IAAW,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,CAAgC;IACrE,IAAW,aAAa,IAAI,MAAM,CAAC,MAAM,CAAC,CAAqC;IAC/E,IAAW,QAAQ,IAAI,MAAM,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAgC;IAE7F,IAAW,MAAM,IAAI,OAAO,CAM3B;IACD,IAAW,OAAO,IAAI,gBAAgB,CAGrC;IACD,IAAW,IAAI,IAAI,MAAM,CAA4B;IACrD,IAAW,IAAI,IAAI,MAAM,CAA4B;IACrD,IAAW,MAAM,IAAI,mBAAmB,CAMvC;IACD,IAAW,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,CAG3C;IACM,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAI3C,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAK1D,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAGrD,OAAO,IAAI,IAAI;IAGf,KAAK,IAAI,IAAI;IAGb,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI;IAG7D,SAAS,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI;IAGxD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI;IAI/D,SAAS,CAAC,GAAG,EAAE,WAAW,GAAG,WAAW,GAAG,aAAa,GAAG,YAAY,GAAG,UAAU,GAAG,cAAc,GAAG,UAAU,GAAG,eAAe,GAAG,MAAM;IAC7I,SAAS,CAAC,GAAG,EAAE,mBAAmB,GAAG,qBAAqB,GAAG,cAAc,GAAG,YAAY,GAAG,aAAa,GAAG,cAAc,GAAG,iBAAiB,GAAG,uBAAuB,GAAG,WAAW,GAAG,YAAY,GAAG,OAAO;IAChN,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,eAAe,GAAG,YAAY,GAAG,MAAM,GAAG,cAAc,GAAG,YAAY,GAAG,MAAM;IACrH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG;IAI3B,SAAS,CAAC,GAAG,EAAE,WAAW,GAAG,YAAY,GAAG,UAAU,GAAG,eAAe,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAC9F,SAAS,CAAC,GAAG,EAAE,YAAY,GAAG,gBAAgB,EAAE,KAAK,EAAE,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,IAAI;IAChK,SAAS,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,IAAI;IACpF,SAAS,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI;IAC9E,SAAS,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,KAAK,GAAG,IAAI;IACzE,SAAS,CAAC,GAAG,EAAE,mBAAmB,GAAG,qBAAqB,GAAG,cAAc,GAAG,YAAY,GAAG,aAAa,GAAG,cAAc,GAAG,iBAAiB,GAAG,uBAAuB,GAAG,WAAW,GAAG,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAC7N,SAAS,CAAC,GAAG,EAAE,UAAU,GAAG,eAAe,GAAG,YAAY,GAAG,cAAc,GAAG,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAChH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IACpD,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAIxC,KAAK,IAAI,IAAI;IAIpB,OAAO,CAAC,eAAe;CAOxB"} \ No newline at end of file diff --git a/headless/headless/public/Terminal.js b/headless/headless/public/Terminal.js new file mode 100644 index 000000000..1718c3b66 --- /dev/null +++ b/headless/headless/public/Terminal.js @@ -0,0 +1,147 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Terminal = void 0; +var BufferNamespaceApi_1 = require("common/public/BufferNamespaceApi"); +var ParserApi_1 = require("common/public/ParserApi"); +var UnicodeApi_1 = require("common/public/UnicodeApi"); +var Terminal_1 = require("headless/Terminal"); +var Terminal = (function () { + function Terminal(options) { + this._core = new Terminal_1.Terminal(options); + } + Terminal.prototype._checkProposedApi = function () { + if (!this._core.optionsService.options.allowProposedApi) { + throw new Error('You must set the allowProposedApi option to true to use proposed API'); + } + }; + Object.defineProperty(Terminal.prototype, "onCursorMove", { + get: function () { return this._core.onCursorMove; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "onLineFeed", { + get: function () { return this._core.onLineFeed; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "onData", { + get: function () { return this._core.onData; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "onBinary", { + get: function () { return this._core.onBinary; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "onTitleChange", { + get: function () { return this._core.onTitleChange; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "onResize", { + get: function () { return this._core.onResize; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "parser", { + get: function () { + this._checkProposedApi(); + if (!this._parser) { + this._parser = new ParserApi_1.ParserApi(this._core); + } + return this._parser; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "unicode", { + get: function () { + this._checkProposedApi(); + return new UnicodeApi_1.UnicodeApi(this._core); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "rows", { + get: function () { return this._core.rows; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "cols", { + get: function () { return this._core.cols; }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "buffer", { + get: function () { + this._checkProposedApi(); + if (!this._buffer) { + this._buffer = new BufferNamespaceApi_1.BufferNamespaceApi(this._core); + } + return this._buffer; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Terminal.prototype, "markers", { + get: function () { + this._checkProposedApi(); + return this._core.markers; + }, + enumerable: false, + configurable: true + }); + Terminal.prototype.resize = function (columns, rows) { + this._verifyIntegers(columns, rows); + this._core.resize(columns, rows); + }; + Terminal.prototype.registerMarker = function (cursorYOffset) { + this._checkProposedApi(); + this._verifyIntegers(cursorYOffset); + return this._core.addMarker(cursorYOffset); + }; + Terminal.prototype.addMarker = function (cursorYOffset) { + return this.registerMarker(cursorYOffset); + }; + Terminal.prototype.dispose = function () { + this._core.dispose(); + }; + Terminal.prototype.clear = function () { + this._core.clear(); + }; + Terminal.prototype.write = function (data, callback) { + this._core.write(data, callback); + }; + Terminal.prototype.writeUtf8 = function (data, callback) { + this._core.write(data, callback); + }; + Terminal.prototype.writeln = function (data, callback) { + this._core.write(data); + this._core.write('\r\n', callback); + }; + Terminal.prototype.getOption = function (key) { + return this._core.optionsService.getOption(key); + }; + Terminal.prototype.setOption = function (key, value) { + this._core.optionsService.setOption(key, value); + }; + Terminal.prototype.reset = function () { + this._core.reset(); + }; + Terminal.prototype._verifyIntegers = function () { + var values = []; + for (var _i = 0; _i < arguments.length; _i++) { + values[_i] = arguments[_i]; + } + for (var _a = 0, values_1 = values; _a < values_1.length; _a++) { + var value = values_1[_a]; + if (value === Infinity || isNaN(value) || value % 1 !== 0) { + throw new Error('This API only accepts integers'); + } + } + }; + return Terminal; +}()); +exports.Terminal = Terminal; +//# sourceMappingURL=Terminal.js.map \ No newline at end of file diff --git a/headless/headless/public/Terminal.js.map b/headless/headless/public/Terminal.js.map new file mode 100644 index 000000000..6e27bbc7d --- /dev/null +++ b/headless/headless/public/Terminal.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Terminal.js","sourceRoot":"","sources":["../../../src/headless/public/Terminal.ts"],"names":[],"mappings":";;;AAMA,uEAAsE;AACtE,qDAAoD;AACpD,uDAAsD;AAEtD,8CAA6D;AAE7D;IAKE,kBAAY,OAA0B;QACpC,IAAI,CAAC,KAAK,GAAG,IAAI,mBAAY,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAEO,oCAAiB,GAAzB;QACE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,gBAAgB,EAAE;YACvD,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;SACzF;IACH,CAAC;IAED,sBAAW,kCAAY;aAAvB,cAA0C,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;;;OAAA;IAC3E,sBAAW,gCAAU;aAArB,cAAwC,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;;;OAAA;IACvE,sBAAW,4BAAM;aAAjB,cAAsC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;;;OAAA;IACjE,sBAAW,8BAAQ;aAAnB,cAAwC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;;;OAAA;IACrE,sBAAW,mCAAa;aAAxB,cAA6C,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;;;OAAA;IAC/E,sBAAW,8BAAQ;aAAnB,cAAgE,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;;;OAAA;IAE7F,sBAAW,4BAAM;aAAjB;YACE,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACjB,IAAI,CAAC,OAAO,GAAG,IAAI,qBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAC1C;YACD,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;;;OAAA;IACD,sBAAW,6BAAO;aAAlB;YACE,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzB,OAAO,IAAI,uBAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC;;;OAAA;IACD,sBAAW,0BAAI;aAAf,cAA4B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;;;OAAA;IACrD,sBAAW,0BAAI;aAAf,cAA4B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;;;OAAA;IACrD,sBAAW,4BAAM;aAAjB;YACE,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACjB,IAAI,CAAC,OAAO,GAAG,IAAI,uCAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACnD;YACD,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;;;OAAA;IACD,sBAAW,6BAAO;aAAlB;YACE,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;QAC5B,CAAC;;;OAAA;IACM,yBAAM,GAAb,UAAc,OAAe,EAAE,IAAY;QACzC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IACM,iCAAc,GAArB,UAAsB,aAAqB;QACzC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IAC7C,CAAC;IACM,4BAAS,GAAhB,UAAiB,aAAqB;QACpC,OAAO,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;IAC5C,CAAC;IACM,0BAAO,GAAd;QACE,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;IACM,wBAAK,GAAZ;QACE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IACM,wBAAK,GAAZ,UAAa,IAAyB,EAAE,QAAqB;QAC3D,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IACM,4BAAS,GAAhB,UAAiB,IAAgB,EAAE,QAAqB;QACtD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IACM,0BAAO,GAAd,UAAe,IAAyB,EAAE,QAAqB;QAC7D,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACrC,CAAC;IAKM,4BAAS,GAAhB,UAAiB,GAAQ;QACvB,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAClD,CAAC;IAUM,4BAAS,GAAhB,UAAiB,GAAQ,EAAE,KAAU;QACnC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAClD,CAAC;IACM,wBAAK,GAAZ;QACE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAEO,kCAAe,GAAvB;QAAwB,gBAAmB;aAAnB,UAAmB,EAAnB,qBAAmB,EAAnB,IAAmB;YAAnB,2BAAmB;;QACzC,KAAoB,UAAM,EAAN,iBAAM,EAAN,oBAAM,EAAN,IAAM,EAAE;YAAvB,IAAM,KAAK,eAAA;YACd,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,KAAK,CAAC,EAAE;gBACzD,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;aACnD;SACF;IACH,CAAC;IACH,eAAC;AAAD,CAAC,AAxGD,IAwGC;AAxGY,4BAAQ"} \ No newline at end of file diff --git a/headless/headless/tsconfig.tsbuildinfo b/headless/headless/tsconfig.tsbuildinfo new file mode 100644 index 000000000..7307c7473 --- /dev/null +++ b/headless/headless/tsconfig.tsbuildinfo @@ -0,0 +1,1120 @@ +{ + "program": { + "fileInfos": { + "../../node_modules/typescript/lib/lib.es5.d.ts": { + "version": "b3584bc5798ed422ce2516df360ffa9cf2d80b5eae852867db9ba3743145f895", + "signature": "b3584bc5798ed422ce2516df360ffa9cf2d80b5eae852867db9ba3743145f895", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2015.d.ts": { + "version": "dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6", + "signature": "dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6", + "affectsGlobalScope": false + }, + "../../node_modules/typescript/lib/lib.es2016.d.ts": { + "version": "7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467", + "signature": "7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467", + "affectsGlobalScope": false + }, + "../../node_modules/typescript/lib/lib.es2017.d.ts": { + "version": "8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9", + "signature": "8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9", + "affectsGlobalScope": false + }, + "../../node_modules/typescript/lib/lib.es2018.d.ts": { + "version": "5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06", + "signature": "5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06", + "affectsGlobalScope": false + }, + "../../node_modules/typescript/lib/lib.dom.d.ts": { + "version": "feeeb1dd8a80fb76be42b0426e8f3ffa9bdef3c2f3c12c147e7660b1c5ba8b3b", + "signature": "feeeb1dd8a80fb76be42b0426e8f3ffa9bdef3c2f3c12c147e7660b1c5ba8b3b", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2015.core.d.ts": { + "version": "46ee15e9fefa913333b61eaf6b18885900b139867d89832a515059b62cf16a17", + "signature": "46ee15e9fefa913333b61eaf6b18885900b139867d89832a515059b62cf16a17", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2015.collection.d.ts": { + "version": "43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c", + "signature": "43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2015.generator.d.ts": { + "version": "cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a", + "signature": "cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2015.iterable.d.ts": { + "version": "8b2a5df1ce95f78f6b74f1a555ccdb6baab0486b42d8345e0871dd82811f9b9a", + "signature": "8b2a5df1ce95f78f6b74f1a555ccdb6baab0486b42d8345e0871dd82811f9b9a", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2015.promise.d.ts": { + "version": "2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c", + "signature": "2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2015.proxy.d.ts": { + "version": "810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357", + "signature": "810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2015.reflect.d.ts": { + "version": "62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6", + "signature": "62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2015.symbol.d.ts": { + "version": "3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93", + "signature": "3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts": { + "version": "9d122b7e8c1a5c72506eea50c0973cba55b92b5532d5cafa8a6ce2c547d57551", + "signature": "9d122b7e8c1a5c72506eea50c0973cba55b92b5532d5cafa8a6ce2c547d57551", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2016.array.include.d.ts": { + "version": "3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006", + "signature": "3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2017.object.d.ts": { + "version": "17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a", + "signature": "17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts": { + "version": "7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98", + "signature": "7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2017.string.d.ts": { + "version": "6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577", + "signature": "6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2017.intl.d.ts": { + "version": "12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d", + "signature": "12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts": { + "version": "b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e", + "signature": "b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts": { + "version": "0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a", + "signature": "0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts": { + "version": "a40c4d82bf13fcded295ac29f354eb7d40249613c15e07b53f2fc75e45e16359", + "signature": "a40c4d82bf13fcded295ac29f354eb7d40249613c15e07b53f2fc75e45e16359", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2018.intl.d.ts": { + "version": "df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e", + "signature": "df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2018.promise.d.ts": { + "version": "bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c", + "signature": "bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2018.regexp.d.ts": { + "version": "c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8", + "signature": "c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.es2020.bigint.d.ts": { + "version": "7b5a10e3c897fabece5a51aa85b4111727d7adb53c2734b5d37230ff96802a09", + "signature": "7b5a10e3c897fabece5a51aa85b4111727d7adb53c2734b5d37230ff96802a09", + "affectsGlobalScope": true + }, + "../../node_modules/typescript/lib/lib.esnext.intl.d.ts": { + "version": "506b80b9951c9381dc5f11897b31fca5e2a65731d96ddefa19687fbc26b23c6e", + "signature": "506b80b9951c9381dc5f11897b31fca5e2a65731d96ddefa19687fbc26b23c6e", + "affectsGlobalScope": true + }, + "../../out/common/eventemitter.d.ts": { + "version": "5b03a7f7f7f551e3fe0e92da13d2e17e7ad7ee19c41d0637f4edbc120bc06f66", + "signature": "5b03a7f7f7f551e3fe0e92da13d2e17e7ad7ee19c41d0637f4edbc120bc06f66", + "affectsGlobalScope": false + }, + "../../out/common/circularlist.d.ts": { + "version": "f96222a7fe4af80068de748cd4bd0b247359b303c72cc827e887eaf6ef9fb758", + "signature": "f96222a7fe4af80068de748cd4bd0b247359b303c72cc827e887eaf6ef9fb758", + "affectsGlobalScope": false + }, + "../../out/common/parser/constants.d.ts": { + "version": "ae42446973a3c189ecac84723e74828ee292f9392935db874cb27ee19ca89093", + "signature": "ae42446973a3c189ecac84723e74828ee292f9392935db874cb27ee19ca89093", + "affectsGlobalScope": false + }, + "../../src/common/parser/types.d.ts": { + "version": "55b56377b6fa8b93856027f20ebaccd8e0c77d4327e45e45b5e2041cf94011cc", + "signature": "55b56377b6fa8b93856027f20ebaccd8e0c77d4327e45e45b5e2041cf94011cc", + "affectsGlobalScope": false + }, + "../../src/common/buffer/types.d.ts": { + "version": "5e2f59fc5cb1b39a2e163bafe30139a33dac4033edcb9b1b831d542abb7f7bae", + "signature": "5e2f59fc5cb1b39a2e163bafe30139a33dac4033edcb9b1b831d542abb7f7bae", + "affectsGlobalScope": false + }, + "../../out/common/services/services.d.ts": { + "version": "4672a4d6d71a25b4592922ecd70094e932348a031d39acc4cef027ea9b62cba0", + "signature": "4672a4d6d71a25b4592922ecd70094e932348a031d39acc4cef027ea9b62cba0", + "affectsGlobalScope": false + }, + "../../src/common/types.d.ts": { + "version": "d7d8eb9c47232c80348f2fc6c8eb7d3acb329b6d8fdcf1f1c38d6e5099f8370b", + "signature": "d7d8eb9c47232c80348f2fc6c8eb7d3acb329b6d8fdcf1f1c38d6e5099f8370b", + "affectsGlobalScope": false + }, + "../../out/common/buffer/constants.d.ts": { + "version": "ff74cff1b7fe399447fd661d0c68586e7b991d11d044af133963c04bde38a852", + "signature": "ff74cff1b7fe399447fd661d0c68586e7b991d11d044af133963c04bde38a852", + "affectsGlobalScope": false + }, + "../../out/common/buffer/attributedata.d.ts": { + "version": "421bb313e7b328ba640853d13b584fe7815b818bd02584d020a41b7a7120d262", + "signature": "421bb313e7b328ba640853d13b584fe7815b818bd02584d020a41b7a7120d262", + "affectsGlobalScope": false + }, + "../../out/common/buffer/bufferline.d.ts": { + "version": "baaa0fc61cb33a67caa0abb986740700be9313c6866ed78c17193e87ca7057a1", + "signature": "baaa0fc61cb33a67caa0abb986740700be9313c6866ed78c17193e87ca7057a1", + "affectsGlobalScope": false + }, + "../../out/common/lifecycle.d.ts": { + "version": "0ba457ac19650eb9dffb8216ca42947899613be5aee16f3809fe39187c30423e", + "signature": "0ba457ac19650eb9dffb8216ca42947899613be5aee16f3809fe39187c30423e", + "affectsGlobalScope": false + }, + "../../out/common/inputhandler.d.ts": { + "version": "542507ad71abebbfe8b5da8758e1aa47bfce3acd0da245f10885cab9934b71d6", + "signature": "542507ad71abebbfe8b5da8758e1aa47bfce3acd0da245f10885cab9934b71d6", + "affectsGlobalScope": false + }, + "../../out/common/coreterminal.d.ts": { + "version": "ab615cd4d0ef6f17d26eef27cdf5beec0e081e59b5eefb09ede878c2cabb4c15", + "signature": "ab615cd4d0ef6f17d26eef27cdf5beec0e081e59b5eefb09ede878c2cabb4c15", + "affectsGlobalScope": false + }, + "../../src/headless/terminal.ts": { + "version": "59209d1535dcfbe8bac847ccf13e829a9ea692ce58fdcb3ee3605791ae60b564", + "signature": "5311ffa92a616a0729010de20af2272185a8b65b51ac26a496326b3b32aad8cc", + "affectsGlobalScope": false + }, + "../../src/headless/types.d.ts": { + "version": "d51941b70feb73ac171f24e34f11de9be17d0c4f224da1a6ed39fe8c31ba6695", + "signature": "d51941b70feb73ac171f24e34f11de9be17d0c4f224da1a6ed39fe8c31ba6695", + "affectsGlobalScope": false + }, + "../../out/common/public/buffernamespaceapi.d.ts": { + "version": "1f8e93ce424bd436ad641d8313d849af586a3779adbfd870e1cfee72a212ae57", + "signature": "1f8e93ce424bd436ad641d8313d849af586a3779adbfd870e1cfee72a212ae57", + "affectsGlobalScope": false + }, + "../../out/common/public/parserapi.d.ts": { + "version": "7c0d242565ad3b41ef8666e46fbd88aec222d2e9b2a343ac315b00373401ffc2", + "signature": "7c0d242565ad3b41ef8666e46fbd88aec222d2e9b2a343ac315b00373401ffc2", + "affectsGlobalScope": false + }, + "../../out/common/public/unicodeapi.d.ts": { + "version": "d77b28e85c1bbc95897707b719c4797ac94f5bf76572c81baae195787133826c", + "signature": "d77b28e85c1bbc95897707b719c4797ac94f5bf76572c81baae195787133826c", + "affectsGlobalScope": false + }, + "../../src/headless/public/terminal.ts": { + "version": "fce93b9408e0c088a1c6802aff2cf8cc46ac0feddc59f26b5a3241d0f03c82db", + "signature": "503924e7f37322f587ebce5459da9c47860c843c0d30d6d09b6ba25d5d169ac7", + "affectsGlobalScope": false + }, + "../../typings/xterm.d.ts": { + "version": "d5256f76893350e4897436490570d291be7a2a005d44e3fa221f1a19804b8c5e", + "signature": "d5256f76893350e4897436490570d291be7a2a005d44e3fa221f1a19804b8c5e", + "affectsGlobalScope": false + }, + "../../typings/xterm-core.d.ts": { + "version": "675fd5779b700c3e864a36a14db728d91027632f90e60c7bfd440b5db61e174d", + "signature": "675fd5779b700c3e864a36a14db728d91027632f90e60c7bfd440b5db61e174d", + "affectsGlobalScope": false + }, + "../../node_modules/@types/mocha/index.d.ts": { + "version": "0359800d3b440f8515001431cde1500944e156040577425eb3f7b80af0846612", + "signature": "0359800d3b440f8515001431cde1500944e156040577425eb3f7b80af0846612", + "affectsGlobalScope": true + }, + "../../node_modules/@types/node/globals.d.ts": { + "version": "25b4a0c4fab47c373ee49df4c239826ee3430019fc0c1b5e59edc3e398b7468d", + "signature": "25b4a0c4fab47c373ee49df4c239826ee3430019fc0c1b5e59edc3e398b7468d", + "affectsGlobalScope": true + }, + "../../node_modules/@types/node/async_hooks.d.ts": { + "version": "c9e8a340da877b05a52525554aa255b3f44958c7f6748ebf5cbe0bfbe6766878", + "signature": "c9e8a340da877b05a52525554aa255b3f44958c7f6748ebf5cbe0bfbe6766878", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/buffer.d.ts": { + "version": "a473cf45c3d9809518f8af913312139d9f4db6887dc554e0d06d0f4e52722e6b", + "signature": "a473cf45c3d9809518f8af913312139d9f4db6887dc554e0d06d0f4e52722e6b", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/child_process.d.ts": { + "version": "a668dfae917097b30fc29bbebeeb869cee22529f2aa9976cea03c7e834a1b841", + "signature": "a668dfae917097b30fc29bbebeeb869cee22529f2aa9976cea03c7e834a1b841", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/cluster.d.ts": { + "version": "04eaa93bd75f937f9184dcb95a7983800c5770cf8ddd8ac0f3734dc02f5b20ef", + "signature": "04eaa93bd75f937f9184dcb95a7983800c5770cf8ddd8ac0f3734dc02f5b20ef", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/console.d.ts": { + "version": "c8155caf28fc7b0a564156a5df28ad8a844a3bd32d331d148d8f3ce88025c870", + "signature": "c8155caf28fc7b0a564156a5df28ad8a844a3bd32d331d148d8f3ce88025c870", + "affectsGlobalScope": true + }, + "../../node_modules/@types/node/constants.d.ts": { + "version": "45ac321f2e15d268fd74a90ddaa6467dcaaff2c5b13f95b4b85831520fb7a491", + "signature": "45ac321f2e15d268fd74a90ddaa6467dcaaff2c5b13f95b4b85831520fb7a491", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/crypto.d.ts": { + "version": "0084b54e281a37c75079f92ca20603d5731de063e7a425852b2907de4dd19932", + "signature": "0084b54e281a37c75079f92ca20603d5731de063e7a425852b2907de4dd19932", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/dgram.d.ts": { + "version": "797a9d37eb1f76143311c3f0a186ce5c0d8735e94c0ca08ff8712a876c9b4f9e", + "signature": "797a9d37eb1f76143311c3f0a186ce5c0d8735e94c0ca08ff8712a876c9b4f9e", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/dns.d.ts": { + "version": "bc31e01146eec89eb870b9ad8c55d759bcbc8989a894e6f0f81f832e0d10eb04", + "signature": "bc31e01146eec89eb870b9ad8c55d759bcbc8989a894e6f0f81f832e0d10eb04", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/domain.d.ts": { + "version": "2866a528b2708aa272ec3eaafd3c980abb23aec1ef831cfc5eb2186b98c37ce5", + "signature": "2866a528b2708aa272ec3eaafd3c980abb23aec1ef831cfc5eb2186b98c37ce5", + "affectsGlobalScope": true + }, + "../../node_modules/@types/node/events.d.ts": { + "version": "153d835dc32985120790e10102834b0a5bd979bb5e42bfbb33c0ff6260cf03ce", + "signature": "153d835dc32985120790e10102834b0a5bd979bb5e42bfbb33c0ff6260cf03ce", + "affectsGlobalScope": true + }, + "../../node_modules/@types/node/fs.d.ts": { + "version": "a44c87a409b60f211a240341905d818f5f173420dcf7f989ee6c8a1a3d812ae9", + "signature": "a44c87a409b60f211a240341905d818f5f173420dcf7f989ee6c8a1a3d812ae9", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/fs/promises.d.ts": { + "version": "bdaf554ae2d9d09e2a42f58a29ef7f80e5b5c1d7b96bfb717243dc91a477216e", + "signature": "bdaf554ae2d9d09e2a42f58a29ef7f80e5b5c1d7b96bfb717243dc91a477216e", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/http.d.ts": { + "version": "dce8672a79c7221c10a355b905940ab57505bc480a72a5da33ba24cbf82bb75c", + "signature": "dce8672a79c7221c10a355b905940ab57505bc480a72a5da33ba24cbf82bb75c", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/http2.d.ts": { + "version": "321ea733ae7f611077a2d7b4bc378ac4a6b7e365e1a51c71a7e5b2818e1e310a", + "signature": "321ea733ae7f611077a2d7b4bc378ac4a6b7e365e1a51c71a7e5b2818e1e310a", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/https.d.ts": { + "version": "13257840c0850d4ebd7c2b17604a9e006f752de76c2400ebc752bc465c330452", + "signature": "13257840c0850d4ebd7c2b17604a9e006f752de76c2400ebc752bc465c330452", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/inspector.d.ts": { + "version": "42176966283d3835c34278b9b5c0f470d484c0c0c6a55c20a2c916a1ce69b6e8", + "signature": "42176966283d3835c34278b9b5c0f470d484c0c0c6a55c20a2c916a1ce69b6e8", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/module.d.ts": { + "version": "0cff7901aedfe78e314f7d44088f07e2afa1b6e4f0473a4169b8456ca2fb245d", + "signature": "0cff7901aedfe78e314f7d44088f07e2afa1b6e4f0473a4169b8456ca2fb245d", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/net.d.ts": { + "version": "40b957b502b40dd490ee334aed47a30636f8d14a0267d1b6c088c2be1dcf2757", + "signature": "40b957b502b40dd490ee334aed47a30636f8d14a0267d1b6c088c2be1dcf2757", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/os.d.ts": { + "version": "69640cc2e76dad52daeb9914e6b70c5c9a5591a3a65190a2d3ea432cf0015e16", + "signature": "69640cc2e76dad52daeb9914e6b70c5c9a5591a3a65190a2d3ea432cf0015e16", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/path.d.ts": { + "version": "21e64a125f65dff99cc3ed366c96e922b90daed343eb52ecdace5f220401dcda", + "signature": "21e64a125f65dff99cc3ed366c96e922b90daed343eb52ecdace5f220401dcda", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/perf_hooks.d.ts": { + "version": "4982d94cb6427263c8839d8d6324a8bbe129e931deb61a7380f8fad17ba2cfc0", + "signature": "4982d94cb6427263c8839d8d6324a8bbe129e931deb61a7380f8fad17ba2cfc0", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/process.d.ts": { + "version": "b0b00cf2e8107ab671243a73d2fbd6296a853bebe3fcfaaca293f65aaa245eaf", + "signature": "b0b00cf2e8107ab671243a73d2fbd6296a853bebe3fcfaaca293f65aaa245eaf", + "affectsGlobalScope": true + }, + "../../node_modules/@types/node/punycode.d.ts": { + "version": "7f77304372efe3c9967e5f9ea2061f1b4bf41dc3cda3c83cdd676f2e5af6b7e6", + "signature": "7f77304372efe3c9967e5f9ea2061f1b4bf41dc3cda3c83cdd676f2e5af6b7e6", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/querystring.d.ts": { + "version": "992c6f6be16c0a1d2eec13ece33adeea2c747ba27fcd078353a8f4bb5b4fea58", + "signature": "992c6f6be16c0a1d2eec13ece33adeea2c747ba27fcd078353a8f4bb5b4fea58", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/readline.d.ts": { + "version": "3b790d08129aca55fd5ae1672d1d26594147ac0d5f2eedc30c7575eb18daef7e", + "signature": "3b790d08129aca55fd5ae1672d1d26594147ac0d5f2eedc30c7575eb18daef7e", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/repl.d.ts": { + "version": "64535caf208a02420d2d04eb2029269efedd11eb8597ada0d5e6f3d54ec663ae", + "signature": "64535caf208a02420d2d04eb2029269efedd11eb8597ada0d5e6f3d54ec663ae", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/stream.d.ts": { + "version": "e7b5a3f40f19d9eea71890c70dfb37ac5dd82cbffe5f95bc8f23c536455732d0", + "signature": "e7b5a3f40f19d9eea71890c70dfb37ac5dd82cbffe5f95bc8f23c536455732d0", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/string_decoder.d.ts": { + "version": "4fd3c4debadce3e9ab9dec3eb45f7f5e2e3d4ad65cf975a6d938d883cfb25a50", + "signature": "4fd3c4debadce3e9ab9dec3eb45f7f5e2e3d4ad65cf975a6d938d883cfb25a50", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/timers.d.ts": { + "version": "0953427f9c2498f71dd912fdd8a81b19cf6925de3e1ad67ab9a77b9a0f79bf0b", + "signature": "0953427f9c2498f71dd912fdd8a81b19cf6925de3e1ad67ab9a77b9a0f79bf0b", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/tls.d.ts": { + "version": "f89a6d56f0267f6e73c707f8a89d2f38e9928e10bfa505f39a4f4bf954093aee", + "signature": "f89a6d56f0267f6e73c707f8a89d2f38e9928e10bfa505f39a4f4bf954093aee", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/trace_events.d.ts": { + "version": "7df562288f949945cf69c21cd912100c2afedeeb7cdb219085f7f4b46cb7dde4", + "signature": "7df562288f949945cf69c21cd912100c2afedeeb7cdb219085f7f4b46cb7dde4", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/tty.d.ts": { + "version": "9d16690485ff1eb4f6fc57aebe237728fd8e03130c460919da3a35f4d9bd97f5", + "signature": "9d16690485ff1eb4f6fc57aebe237728fd8e03130c460919da3a35f4d9bd97f5", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/url.d.ts": { + "version": "dcc6910d95a3625fd2b0487fda055988e46ab46c357a1b3618c27b4a8dd739c9", + "signature": "dcc6910d95a3625fd2b0487fda055988e46ab46c357a1b3618c27b4a8dd739c9", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/util.d.ts": { + "version": "e649840284bab8c4d09cadc125cd7fbde7529690cc1a0881872b6a9cd202819b", + "signature": "e649840284bab8c4d09cadc125cd7fbde7529690cc1a0881872b6a9cd202819b", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/v8.d.ts": { + "version": "a364b4a8a015ae377052fa4fac94204d79a69d879567f444c7ceff1b7a18482d", + "signature": "a364b4a8a015ae377052fa4fac94204d79a69d879567f444c7ceff1b7a18482d", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/vm.d.ts": { + "version": "1aa7dbace2b7b2ef60897dcd4f66252ee6ba85e594ded8918c9acdcecda1896c", + "signature": "1aa7dbace2b7b2ef60897dcd4f66252ee6ba85e594ded8918c9acdcecda1896c", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/worker_threads.d.ts": { + "version": "6c63cb179eda2be5ab45dc146fa4151bec8ce4781986935fe40adfc69cbbf214", + "signature": "6c63cb179eda2be5ab45dc146fa4151bec8ce4781986935fe40adfc69cbbf214", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/zlib.d.ts": { + "version": "4926467de88a92a4fc9971d8c6f21b91eca1c0e7fc2a46cc4638ab9440c73875", + "signature": "4926467de88a92a4fc9971d8c6f21b91eca1c0e7fc2a46cc4638ab9440c73875", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/globals.global.d.ts": { + "version": "2708349d5a11a5c2e5f3a0765259ebe7ee00cdcc8161cb9990cb4910328442a1", + "signature": "2708349d5a11a5c2e5f3a0765259ebe7ee00cdcc8161cb9990cb4910328442a1", + "affectsGlobalScope": true + }, + "../../node_modules/@types/node/wasi.d.ts": { + "version": "4e0a4d84b15692ea8669fe4f3d05a4f204567906b1347da7a58b75f45bae48d3", + "signature": "4e0a4d84b15692ea8669fe4f3d05a4f204567906b1347da7a58b75f45bae48d3", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/ts3.6/base.d.ts": { + "version": "ae68a04912ee5a0f589276f9ec60b095f8c40d48128a4575b3fdd7d93806931c", + "signature": "ae68a04912ee5a0f589276f9ec60b095f8c40d48128a4575b3fdd7d93806931c", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/assert.d.ts": { + "version": "b3593bd345ebea5e4d0a894c03251a3774b34df3d6db57075c18e089a599ba76", + "signature": "b3593bd345ebea5e4d0a894c03251a3774b34df3d6db57075c18e089a599ba76", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/base.d.ts": { + "version": "e61a21e9418f279bc480394a94d1581b2dee73747adcbdef999b6737e34d721b", + "signature": "e61a21e9418f279bc480394a94d1581b2dee73747adcbdef999b6737e34d721b", + "affectsGlobalScope": false + }, + "../../node_modules/@types/node/index.d.ts": { + "version": "6c137dee82a61e14a1eb6a0ba56925b66fd83abf15acf72fe59a10b15e80e319", + "signature": "6c137dee82a61e14a1eb6a0ba56925b66fd83abf15acf72fe59a10b15e80e319", + "affectsGlobalScope": false + } + }, + "options": { + "target": 1, + "lib": [ + "lib.es2015.d.ts", + "lib.es2016.array.include.d.ts" + ], + "rootDir": "../../src", + "sourceMap": true, + "removeComments": true, + "pretty": true, + "incremental": true, + "experimentalDecorators": true, + "composite": true, + "strict": true, + "declarationMap": true, + "outDir": "..", + "types": [ + "../../node_modules/@types/mocha", + "../../node_modules/@types/node" + ], + "baseUrl": "../../src", + "extendedDiagnostics": true, + "paths": { + "common/*": [ + "./common/*" + ] + }, + "pathsBasePath": "D:/GitHub/Tyriar/xterm.js/src/headless", + "watch": true, + "preserveWatchOutput": true, + "configFilePath": "../../src/headless/tsconfig.json" + }, + "referencedMap": { + "../../node_modules/@types/node/base.d.ts": [ + "../../node_modules/@types/node/assert.d.ts", + "../../node_modules/@types/node/ts3.6/base.d.ts" + ], + "../../node_modules/@types/node/child_process.d.ts": [ + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/fs.d.ts", + "../../node_modules/@types/node/net.d.ts", + "../../node_modules/@types/node/stream.d.ts" + ], + "../../node_modules/@types/node/cluster.d.ts": [ + "../../node_modules/@types/node/child_process.d.ts", + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/net.d.ts" + ], + "../../node_modules/@types/node/console.d.ts": [ + "../../node_modules/@types/node/util.d.ts" + ], + "../../node_modules/@types/node/constants.d.ts": [ + "../../node_modules/@types/node/crypto.d.ts", + "../../node_modules/@types/node/fs.d.ts", + "../../node_modules/@types/node/os.d.ts" + ], + "../../node_modules/@types/node/crypto.d.ts": [ + "../../node_modules/@types/node/stream.d.ts" + ], + "../../node_modules/@types/node/dgram.d.ts": [ + "../../node_modules/@types/node/dns.d.ts", + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/net.d.ts" + ], + "../../node_modules/@types/node/domain.d.ts": [ + "../../node_modules/@types/node/events.d.ts" + ], + "../../node_modules/@types/node/events.d.ts": [ + "../../node_modules/@types/node/events.d.ts" + ], + "../../node_modules/@types/node/fs.d.ts": [ + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/fs/promises.d.ts", + "../../node_modules/@types/node/stream.d.ts", + "../../node_modules/@types/node/url.d.ts" + ], + "../../node_modules/@types/node/fs/promises.d.ts": [ + "../../node_modules/@types/node/fs.d.ts" + ], + "../../node_modules/@types/node/http.d.ts": [ + "../../node_modules/@types/node/net.d.ts", + "../../node_modules/@types/node/stream.d.ts", + "../../node_modules/@types/node/url.d.ts" + ], + "../../node_modules/@types/node/http2.d.ts": [ + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/fs.d.ts", + "../../node_modules/@types/node/http.d.ts", + "../../node_modules/@types/node/net.d.ts", + "../../node_modules/@types/node/stream.d.ts", + "../../node_modules/@types/node/tls.d.ts", + "../../node_modules/@types/node/url.d.ts" + ], + "../../node_modules/@types/node/https.d.ts": [ + "../../node_modules/@types/node/http.d.ts", + "../../node_modules/@types/node/tls.d.ts", + "../../node_modules/@types/node/url.d.ts" + ], + "../../node_modules/@types/node/index.d.ts": [ + "../../node_modules/@types/node/base.d.ts" + ], + "../../node_modules/@types/node/inspector.d.ts": [ + "../../node_modules/@types/node/events.d.ts" + ], + "../../node_modules/@types/node/module.d.ts": [ + "../../node_modules/@types/node/url.d.ts" + ], + "../../node_modules/@types/node/net.d.ts": [ + "../../node_modules/@types/node/dns.d.ts", + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/stream.d.ts" + ], + "../../node_modules/@types/node/perf_hooks.d.ts": [ + "../../node_modules/@types/node/async_hooks.d.ts" + ], + "../../node_modules/@types/node/process.d.ts": [ + "../../node_modules/@types/node/tty.d.ts" + ], + "../../node_modules/@types/node/readline.d.ts": [ + "../../node_modules/@types/node/events.d.ts" + ], + "../../node_modules/@types/node/repl.d.ts": [ + "../../node_modules/@types/node/readline.d.ts", + "../../node_modules/@types/node/util.d.ts", + "../../node_modules/@types/node/vm.d.ts" + ], + "../../node_modules/@types/node/stream.d.ts": [ + "../../node_modules/@types/node/events.d.ts" + ], + "../../node_modules/@types/node/tls.d.ts": [ + "../../node_modules/@types/node/net.d.ts" + ], + "../../node_modules/@types/node/ts3.6/base.d.ts": [ + "../../node_modules/@types/node/async_hooks.d.ts", + "../../node_modules/@types/node/buffer.d.ts", + "../../node_modules/@types/node/child_process.d.ts", + "../../node_modules/@types/node/cluster.d.ts", + "../../node_modules/@types/node/console.d.ts", + "../../node_modules/@types/node/constants.d.ts", + "../../node_modules/@types/node/crypto.d.ts", + "../../node_modules/@types/node/dgram.d.ts", + "../../node_modules/@types/node/dns.d.ts", + "../../node_modules/@types/node/domain.d.ts", + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/fs.d.ts", + "../../node_modules/@types/node/fs/promises.d.ts", + "../../node_modules/@types/node/globals.d.ts", + "../../node_modules/@types/node/globals.global.d.ts", + "../../node_modules/@types/node/http.d.ts", + "../../node_modules/@types/node/http2.d.ts", + "../../node_modules/@types/node/https.d.ts", + "../../node_modules/@types/node/inspector.d.ts", + "../../node_modules/@types/node/module.d.ts", + "../../node_modules/@types/node/net.d.ts", + "../../node_modules/@types/node/os.d.ts", + "../../node_modules/@types/node/path.d.ts", + "../../node_modules/@types/node/perf_hooks.d.ts", + "../../node_modules/@types/node/process.d.ts", + "../../node_modules/@types/node/punycode.d.ts", + "../../node_modules/@types/node/querystring.d.ts", + "../../node_modules/@types/node/readline.d.ts", + "../../node_modules/@types/node/repl.d.ts", + "../../node_modules/@types/node/stream.d.ts", + "../../node_modules/@types/node/string_decoder.d.ts", + "../../node_modules/@types/node/timers.d.ts", + "../../node_modules/@types/node/tls.d.ts", + "../../node_modules/@types/node/trace_events.d.ts", + "../../node_modules/@types/node/tty.d.ts", + "../../node_modules/@types/node/url.d.ts", + "../../node_modules/@types/node/util.d.ts", + "../../node_modules/@types/node/v8.d.ts", + "../../node_modules/@types/node/vm.d.ts", + "../../node_modules/@types/node/wasi.d.ts", + "../../node_modules/@types/node/worker_threads.d.ts", + "../../node_modules/@types/node/zlib.d.ts" + ], + "../../node_modules/@types/node/tty.d.ts": [ + "../../node_modules/@types/node/net.d.ts" + ], + "../../node_modules/@types/node/url.d.ts": [ + "../../node_modules/@types/node/querystring.d.ts" + ], + "../../node_modules/@types/node/v8.d.ts": [ + "../../node_modules/@types/node/stream.d.ts" + ], + "../../node_modules/@types/node/worker_threads.d.ts": [ + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/fs/promises.d.ts", + "../../node_modules/@types/node/stream.d.ts", + "../../node_modules/@types/node/url.d.ts", + "../../node_modules/@types/node/vm.d.ts" + ], + "../../node_modules/@types/node/zlib.d.ts": [ + "../../node_modules/@types/node/stream.d.ts" + ], + "../../out/common/buffer/attributedata.d.ts": [ + "../../out/common/buffer/constants.d.ts", + "../../src/common/types.d.ts" + ], + "../../out/common/buffer/bufferline.d.ts": [ + "../../out/common/buffer/attributedata.d.ts", + "../../src/common/types.d.ts" + ], + "../../out/common/circularlist.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../src/common/types.d.ts" + ], + "../../out/common/coreterminal.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../out/common/inputhandler.d.ts", + "../../out/common/lifecycle.d.ts", + "../../out/common/services/services.d.ts", + "../../src/common/buffer/types.d.ts", + "../../src/common/parser/types.d.ts", + "../../src/common/types.d.ts" + ], + "../../out/common/eventemitter.d.ts": [ + "../../src/common/types.d.ts" + ], + "../../out/common/inputhandler.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../out/common/lifecycle.d.ts", + "../../out/common/services/services.d.ts", + "../../src/common/parser/types.d.ts", + "../../src/common/types.d.ts" + ], + "../../out/common/lifecycle.d.ts": [ + "../../src/common/types.d.ts" + ], + "../../out/common/public/buffernamespaceapi.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../src/common/types.d.ts", + "../../typings/xterm.d.ts" + ], + "../../out/common/public/parserapi.d.ts": [ + "../../src/common/types.d.ts", + "../../typings/xterm.d.ts" + ], + "../../out/common/public/unicodeapi.d.ts": [ + "../../src/common/types.d.ts", + "../../typings/xterm.d.ts" + ], + "../../out/common/services/services.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../src/common/buffer/types.d.ts", + "../../src/common/types.d.ts" + ], + "../../src/common/buffer/types.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../src/common/types.d.ts" + ], + "../../src/common/parser/types.d.ts": [ + "../../out/common/parser/constants.d.ts", + "../../src/common/types.d.ts" + ], + "../../src/common/types.d.ts": [ + "../../out/common/circularlist.d.ts", + "../../out/common/eventemitter.d.ts", + "../../out/common/services/services.d.ts", + "../../src/common/buffer/types.d.ts", + "../../src/common/parser/types.d.ts", + "../../typings/xterm.d.ts" + ], + "../../src/headless/public/terminal.ts": [ + "../../out/common/eventemitter.d.ts", + "../../out/common/public/buffernamespaceapi.d.ts", + "../../out/common/public/parserapi.d.ts", + "../../out/common/public/unicodeapi.d.ts", + "../../src/headless/terminal.ts", + "../../typings/xterm-core.d.ts" + ], + "../../src/headless/terminal.ts": [ + "../../out/common/buffer/bufferline.d.ts", + "../../out/common/coreterminal.d.ts", + "../../out/common/eventemitter.d.ts", + "../../out/common/services/services.d.ts", + "../../src/common/buffer/types.d.ts", + "../../src/common/types.d.ts" + ], + "../../src/headless/types.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../src/common/buffer/types.d.ts", + "../../src/common/parser/types.d.ts", + "../../src/common/types.d.ts" + ] + }, + "exportedModulesMap": { + "../../node_modules/@types/node/base.d.ts": [ + "../../node_modules/@types/node/assert.d.ts", + "../../node_modules/@types/node/ts3.6/base.d.ts" + ], + "../../node_modules/@types/node/child_process.d.ts": [ + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/fs.d.ts", + "../../node_modules/@types/node/net.d.ts", + "../../node_modules/@types/node/stream.d.ts" + ], + "../../node_modules/@types/node/cluster.d.ts": [ + "../../node_modules/@types/node/child_process.d.ts", + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/net.d.ts" + ], + "../../node_modules/@types/node/console.d.ts": [ + "../../node_modules/@types/node/util.d.ts" + ], + "../../node_modules/@types/node/constants.d.ts": [ + "../../node_modules/@types/node/crypto.d.ts", + "../../node_modules/@types/node/fs.d.ts", + "../../node_modules/@types/node/os.d.ts" + ], + "../../node_modules/@types/node/crypto.d.ts": [ + "../../node_modules/@types/node/stream.d.ts" + ], + "../../node_modules/@types/node/dgram.d.ts": [ + "../../node_modules/@types/node/dns.d.ts", + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/net.d.ts" + ], + "../../node_modules/@types/node/domain.d.ts": [ + "../../node_modules/@types/node/events.d.ts" + ], + "../../node_modules/@types/node/events.d.ts": [ + "../../node_modules/@types/node/events.d.ts" + ], + "../../node_modules/@types/node/fs.d.ts": [ + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/fs/promises.d.ts", + "../../node_modules/@types/node/stream.d.ts", + "../../node_modules/@types/node/url.d.ts" + ], + "../../node_modules/@types/node/fs/promises.d.ts": [ + "../../node_modules/@types/node/fs.d.ts" + ], + "../../node_modules/@types/node/http.d.ts": [ + "../../node_modules/@types/node/net.d.ts", + "../../node_modules/@types/node/stream.d.ts", + "../../node_modules/@types/node/url.d.ts" + ], + "../../node_modules/@types/node/http2.d.ts": [ + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/fs.d.ts", + "../../node_modules/@types/node/http.d.ts", + "../../node_modules/@types/node/net.d.ts", + "../../node_modules/@types/node/stream.d.ts", + "../../node_modules/@types/node/tls.d.ts", + "../../node_modules/@types/node/url.d.ts" + ], + "../../node_modules/@types/node/https.d.ts": [ + "../../node_modules/@types/node/http.d.ts", + "../../node_modules/@types/node/tls.d.ts", + "../../node_modules/@types/node/url.d.ts" + ], + "../../node_modules/@types/node/index.d.ts": [ + "../../node_modules/@types/node/base.d.ts" + ], + "../../node_modules/@types/node/inspector.d.ts": [ + "../../node_modules/@types/node/events.d.ts" + ], + "../../node_modules/@types/node/module.d.ts": [ + "../../node_modules/@types/node/url.d.ts" + ], + "../../node_modules/@types/node/net.d.ts": [ + "../../node_modules/@types/node/dns.d.ts", + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/stream.d.ts" + ], + "../../node_modules/@types/node/perf_hooks.d.ts": [ + "../../node_modules/@types/node/async_hooks.d.ts" + ], + "../../node_modules/@types/node/process.d.ts": [ + "../../node_modules/@types/node/tty.d.ts" + ], + "../../node_modules/@types/node/readline.d.ts": [ + "../../node_modules/@types/node/events.d.ts" + ], + "../../node_modules/@types/node/repl.d.ts": [ + "../../node_modules/@types/node/readline.d.ts", + "../../node_modules/@types/node/util.d.ts", + "../../node_modules/@types/node/vm.d.ts" + ], + "../../node_modules/@types/node/stream.d.ts": [ + "../../node_modules/@types/node/events.d.ts" + ], + "../../node_modules/@types/node/tls.d.ts": [ + "../../node_modules/@types/node/net.d.ts" + ], + "../../node_modules/@types/node/ts3.6/base.d.ts": [ + "../../node_modules/@types/node/async_hooks.d.ts", + "../../node_modules/@types/node/buffer.d.ts", + "../../node_modules/@types/node/child_process.d.ts", + "../../node_modules/@types/node/cluster.d.ts", + "../../node_modules/@types/node/console.d.ts", + "../../node_modules/@types/node/constants.d.ts", + "../../node_modules/@types/node/crypto.d.ts", + "../../node_modules/@types/node/dgram.d.ts", + "../../node_modules/@types/node/dns.d.ts", + "../../node_modules/@types/node/domain.d.ts", + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/fs.d.ts", + "../../node_modules/@types/node/fs/promises.d.ts", + "../../node_modules/@types/node/globals.d.ts", + "../../node_modules/@types/node/globals.global.d.ts", + "../../node_modules/@types/node/http.d.ts", + "../../node_modules/@types/node/http2.d.ts", + "../../node_modules/@types/node/https.d.ts", + "../../node_modules/@types/node/inspector.d.ts", + "../../node_modules/@types/node/module.d.ts", + "../../node_modules/@types/node/net.d.ts", + "../../node_modules/@types/node/os.d.ts", + "../../node_modules/@types/node/path.d.ts", + "../../node_modules/@types/node/perf_hooks.d.ts", + "../../node_modules/@types/node/process.d.ts", + "../../node_modules/@types/node/punycode.d.ts", + "../../node_modules/@types/node/querystring.d.ts", + "../../node_modules/@types/node/readline.d.ts", + "../../node_modules/@types/node/repl.d.ts", + "../../node_modules/@types/node/stream.d.ts", + "../../node_modules/@types/node/string_decoder.d.ts", + "../../node_modules/@types/node/timers.d.ts", + "../../node_modules/@types/node/tls.d.ts", + "../../node_modules/@types/node/trace_events.d.ts", + "../../node_modules/@types/node/tty.d.ts", + "../../node_modules/@types/node/url.d.ts", + "../../node_modules/@types/node/util.d.ts", + "../../node_modules/@types/node/v8.d.ts", + "../../node_modules/@types/node/vm.d.ts", + "../../node_modules/@types/node/wasi.d.ts", + "../../node_modules/@types/node/worker_threads.d.ts", + "../../node_modules/@types/node/zlib.d.ts" + ], + "../../node_modules/@types/node/tty.d.ts": [ + "../../node_modules/@types/node/net.d.ts" + ], + "../../node_modules/@types/node/url.d.ts": [ + "../../node_modules/@types/node/querystring.d.ts" + ], + "../../node_modules/@types/node/v8.d.ts": [ + "../../node_modules/@types/node/stream.d.ts" + ], + "../../node_modules/@types/node/worker_threads.d.ts": [ + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/fs/promises.d.ts", + "../../node_modules/@types/node/stream.d.ts", + "../../node_modules/@types/node/url.d.ts", + "../../node_modules/@types/node/vm.d.ts" + ], + "../../node_modules/@types/node/zlib.d.ts": [ + "../../node_modules/@types/node/stream.d.ts" + ], + "../../out/common/buffer/attributedata.d.ts": [ + "../../out/common/buffer/constants.d.ts", + "../../src/common/types.d.ts" + ], + "../../out/common/buffer/bufferline.d.ts": [ + "../../out/common/buffer/attributedata.d.ts", + "../../src/common/types.d.ts" + ], + "../../out/common/circularlist.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../src/common/types.d.ts" + ], + "../../out/common/coreterminal.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../out/common/inputhandler.d.ts", + "../../out/common/lifecycle.d.ts", + "../../out/common/services/services.d.ts", + "../../src/common/buffer/types.d.ts", + "../../src/common/parser/types.d.ts", + "../../src/common/types.d.ts" + ], + "../../out/common/eventemitter.d.ts": [ + "../../src/common/types.d.ts" + ], + "../../out/common/inputhandler.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../out/common/lifecycle.d.ts", + "../../out/common/services/services.d.ts", + "../../src/common/parser/types.d.ts", + "../../src/common/types.d.ts" + ], + "../../out/common/lifecycle.d.ts": [ + "../../src/common/types.d.ts" + ], + "../../out/common/public/buffernamespaceapi.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../src/common/types.d.ts", + "../../typings/xterm.d.ts" + ], + "../../out/common/public/parserapi.d.ts": [ + "../../src/common/types.d.ts", + "../../typings/xterm.d.ts" + ], + "../../out/common/public/unicodeapi.d.ts": [ + "../../src/common/types.d.ts", + "../../typings/xterm.d.ts" + ], + "../../out/common/services/services.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../src/common/buffer/types.d.ts", + "../../src/common/types.d.ts" + ], + "../../src/common/buffer/types.d.ts": [ + "../../src/common/eventemitter.ts", + "../../src/common/types.d.ts" + ], + "../../src/common/parser/types.d.ts": [ + "../../src/common/parser/constants.ts", + "../../src/common/types.d.ts" + ], + "../../src/common/types.d.ts": [ + "../../src/common/buffer/types.d.ts", + "../../src/common/circularlist.ts", + "../../src/common/eventemitter.ts", + "../../src/common/parser/types.d.ts", + "../../src/common/services/services.ts", + "../../typings/xterm.d.ts" + ], + "../../src/headless/public/terminal.ts": [ + "../../out/common/eventemitter.d.ts", + "../../typings/xterm-core.d.ts" + ], + "../../src/headless/terminal.ts": [ + "../../out/common/coreterminal.d.ts", + "../../out/common/eventemitter.d.ts", + "../../out/common/services/services.d.ts", + "../../src/common/buffer/types.d.ts", + "../../src/common/types.d.ts" + ], + "../../src/headless/types.d.ts": [ + "../../out/common/eventemitter.d.ts", + "../../src/common/buffer/types.d.ts", + "../../src/common/parser/types.d.ts", + "../../src/common/types.d.ts" + ] + }, + "semanticDiagnosticsPerFile": [ + "../../node_modules/@types/mocha/index.d.ts", + "../../node_modules/@types/node/assert.d.ts", + "../../node_modules/@types/node/async_hooks.d.ts", + "../../node_modules/@types/node/base.d.ts", + "../../node_modules/@types/node/buffer.d.ts", + "../../node_modules/@types/node/child_process.d.ts", + "../../node_modules/@types/node/cluster.d.ts", + "../../node_modules/@types/node/console.d.ts", + "../../node_modules/@types/node/constants.d.ts", + "../../node_modules/@types/node/crypto.d.ts", + "../../node_modules/@types/node/dgram.d.ts", + "../../node_modules/@types/node/dns.d.ts", + "../../node_modules/@types/node/domain.d.ts", + "../../node_modules/@types/node/events.d.ts", + "../../node_modules/@types/node/fs.d.ts", + "../../node_modules/@types/node/fs/promises.d.ts", + "../../node_modules/@types/node/globals.d.ts", + "../../node_modules/@types/node/globals.global.d.ts", + "../../node_modules/@types/node/http.d.ts", + "../../node_modules/@types/node/http2.d.ts", + "../../node_modules/@types/node/https.d.ts", + "../../node_modules/@types/node/index.d.ts", + "../../node_modules/@types/node/inspector.d.ts", + "../../node_modules/@types/node/module.d.ts", + "../../node_modules/@types/node/net.d.ts", + "../../node_modules/@types/node/os.d.ts", + "../../node_modules/@types/node/path.d.ts", + "../../node_modules/@types/node/perf_hooks.d.ts", + "../../node_modules/@types/node/process.d.ts", + "../../node_modules/@types/node/punycode.d.ts", + "../../node_modules/@types/node/querystring.d.ts", + "../../node_modules/@types/node/readline.d.ts", + "../../node_modules/@types/node/repl.d.ts", + "../../node_modules/@types/node/stream.d.ts", + "../../node_modules/@types/node/string_decoder.d.ts", + "../../node_modules/@types/node/timers.d.ts", + "../../node_modules/@types/node/tls.d.ts", + "../../node_modules/@types/node/trace_events.d.ts", + "../../node_modules/@types/node/ts3.6/base.d.ts", + "../../node_modules/@types/node/tty.d.ts", + "../../node_modules/@types/node/url.d.ts", + "../../node_modules/@types/node/util.d.ts", + "../../node_modules/@types/node/v8.d.ts", + "../../node_modules/@types/node/vm.d.ts", + "../../node_modules/@types/node/wasi.d.ts", + "../../node_modules/@types/node/worker_threads.d.ts", + "../../node_modules/@types/node/zlib.d.ts", + "../../node_modules/typescript/lib/lib.dom.d.ts", + "../../node_modules/typescript/lib/lib.es2015.collection.d.ts", + "../../node_modules/typescript/lib/lib.es2015.core.d.ts", + "../../node_modules/typescript/lib/lib.es2015.d.ts", + "../../node_modules/typescript/lib/lib.es2015.generator.d.ts", + "../../node_modules/typescript/lib/lib.es2015.iterable.d.ts", + "../../node_modules/typescript/lib/lib.es2015.promise.d.ts", + "../../node_modules/typescript/lib/lib.es2015.proxy.d.ts", + "../../node_modules/typescript/lib/lib.es2015.reflect.d.ts", + "../../node_modules/typescript/lib/lib.es2015.symbol.d.ts", + "../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts", + "../../node_modules/typescript/lib/lib.es2016.array.include.d.ts", + "../../node_modules/typescript/lib/lib.es2016.d.ts", + "../../node_modules/typescript/lib/lib.es2017.d.ts", + "../../node_modules/typescript/lib/lib.es2017.intl.d.ts", + "../../node_modules/typescript/lib/lib.es2017.object.d.ts", + "../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts", + "../../node_modules/typescript/lib/lib.es2017.string.d.ts", + "../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts", + "../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts", + "../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts", + "../../node_modules/typescript/lib/lib.es2018.d.ts", + "../../node_modules/typescript/lib/lib.es2018.intl.d.ts", + "../../node_modules/typescript/lib/lib.es2018.promise.d.ts", + "../../node_modules/typescript/lib/lib.es2018.regexp.d.ts", + "../../node_modules/typescript/lib/lib.es2020.bigint.d.ts", + "../../node_modules/typescript/lib/lib.es5.d.ts", + "../../node_modules/typescript/lib/lib.esnext.intl.d.ts", + "../../out/common/buffer/attributedata.d.ts", + "../../out/common/buffer/bufferline.d.ts", + "../../out/common/buffer/constants.d.ts", + "../../out/common/circularlist.d.ts", + "../../out/common/coreterminal.d.ts", + "../../out/common/eventemitter.d.ts", + "../../out/common/inputhandler.d.ts", + "../../out/common/lifecycle.d.ts", + "../../out/common/parser/constants.d.ts", + "../../out/common/public/buffernamespaceapi.d.ts", + "../../out/common/public/parserapi.d.ts", + "../../out/common/public/unicodeapi.d.ts", + "../../out/common/services/services.d.ts", + "../../src/common/buffer/types.d.ts", + "../../src/common/parser/types.d.ts", + "../../src/common/types.d.ts", + "../../src/headless/public/terminal.ts", + "../../src/headless/terminal.ts", + "../../src/headless/types.d.ts", + "../../typings/xterm-core.d.ts", + "../../typings/xterm.d.ts" + ] + }, + "version": "4.2.4" +} \ No newline at end of file diff --git a/headless/headless/types.d.ts b/headless/headless/types.d.ts new file mode 100644 index 000000000..a35f39887 --- /dev/null +++ b/headless/headless/types.d.ts @@ -0,0 +1,32 @@ +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[]; + options: ITerminalOptions; + onCursorMove: IEvent; + onData: IEvent; + onBinary: IEvent; + onLineFeed: IEvent; + onResize: IEvent<{ + cols: number; + rows: number; + }>; + onTitleChange: IEvent; + 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; +} +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/headless/headless/types.d.ts.map b/headless/headless/types.d.ts.map new file mode 100644 index 000000000..7410b0435 --- /dev/null +++ b/headless/headless/types.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/headless/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErF,MAAM,WAAW,SAAU,SAAQ,aAAa;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,UAAU,CAAC;IACpB,OAAO,EAAE,OAAO,EAAE,CAAC;IAEnB,OAAO,EAAE,gBAAgB,CAAC;IAE1B,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9B,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5C,aAAa,CAAC,EAAE,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,GAAG,WAAW,CAAC;IAC5F,aAAa,CAAC,EAAE,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,GAAG,WAAW,CAAC;IACzG,aAAa,CAAC,EAAE,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,OAAO,GAAG,WAAW,CAAC;IAC7E,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,WAAW,CAAC;IAC/E,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IACtD,OAAO,IAAI,IAAI,CAAC;IAChB,KAAK,IAAI,IAAI,CAAC;IACd,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAC9D,KAAK,IAAI,IAAI,CAAC;CACf"} \ No newline at end of file diff --git a/headless/headless/types.js b/headless/headless/types.js new file mode 100644 index 000000000..11e638d1e --- /dev/null +++ b/headless/headless/types.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/headless/headless/types.js.map b/headless/headless/types.js.map new file mode 100644 index 000000000..d651a6aa4 --- /dev/null +++ b/headless/headless/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/headless/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/src/common/public/tsconfig.json b/src/common/public/tsconfig.json deleted file mode 100644 index 6e14ddf70..000000000 --- a/src/common/public/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "extends": "../../tsconfig-library-base", - "compilerOptions": { - "lib": [ - "es2015", - "es2016.Array.Include" - ], - "outDir": "../../../xterm-core", // Temporary outdir to avoid collisions with 'xterm' - "types": [ - "../../../node_modules/@types/mocha", - "../../../node_modules/@types/node" - ], - "baseUrl": "../../", - "extendedDiagnostics": true - }, - "include": [ - "../**/*", - "../../../typings/xterm-core.d.ts", - "../../../typings/xterm.d.ts", // common/Types.d.ts imports from 'xterm' - ], -} diff --git a/src/common/Terminal.ts b/src/headless/Terminal.ts similarity index 100% rename from src/common/Terminal.ts rename to src/headless/Terminal.ts diff --git a/src/common/public/types.ts b/src/headless/Types.d.ts similarity index 99% rename from src/common/public/types.ts rename to src/headless/Types.d.ts index 1c20bd6dd..868e5c178 100644 --- a/src/common/public/types.ts +++ b/src/headless/Types.d.ts @@ -28,4 +28,4 @@ export interface ITerminal extends ICoreTerminal { clear(): void; write(data: string | Uint8Array, callback?: () => void): void; reset(): void; -} \ No newline at end of file +} diff --git a/src/common/public/Terminal.ts b/src/headless/public/Terminal.ts similarity index 98% rename from src/common/public/Terminal.ts rename to src/headless/public/Terminal.ts index 3d195b756..4b27a04b9 100644 --- a/src/common/public/Terminal.ts +++ b/src/headless/public/Terminal.ts @@ -8,7 +8,7 @@ import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi'; import { ParserApi } from 'common/public/ParserApi'; import { UnicodeApi } from 'common/public/UnicodeApi'; import { IBufferNamespace as IBufferNamespaceApi, IMarker, IParser, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-core'; -import { Terminal as TerminalCore } from '../Terminal'; +import { Terminal as TerminalCore } from 'headless/Terminal'; export class Terminal implements ITerminalApi { private _core: TerminalCore; diff --git a/src/headless/tsconfig.json b/src/headless/tsconfig.json new file mode 100644 index 000000000..268bdbdd3 --- /dev/null +++ b/src/headless/tsconfig.json @@ -0,0 +1,27 @@ +{ + "extends": "../tsconfig-library-base", + "compilerOptions": { + "lib": [ + "es2015", + "es2016.Array.Include" + ], + "outDir": "../../headless", // Temporary outdir to avoid collisions with 'xterm' + "types": [ + "../../node_modules/@types/mocha", + "../../node_modules/@types/node" + ], + "baseUrl": "../", + "extendedDiagnostics": true, + "paths": { + "common/*": [ "./common/*" ] + } + }, + "include": [ + "./**/*", + "../../typings/xterm.d.ts", // common/Types.d.ts imports from 'xterm' + "../../typings/xterm-core.d.ts" + ], + "references": [ + { "path": "../common" } + ] +} diff --git a/tsconfig.all.json b/tsconfig.all.json index 009cd498b..6fa02446a 100644 --- a/tsconfig.all.json +++ b/tsconfig.all.json @@ -3,6 +3,7 @@ "include": [], "references": [ { "path": "./src/browser" }, + { "path": "./src/headless" }, { "path": "./test/api" }, { "path": "./test/benchmark" }, { "path": "./addons/xterm-addon-attach" }, From 61ede1cc0d7fd40ba5556c93b20911b3cd5aa5de Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 15:41:24 -0700 Subject: [PATCH 027/164] Update instructions to run --- node-test/README.md | 4 ++-- core-webpack.config.js => webpack.config.core.js | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename core-webpack.config.js => webpack.config.core.js (100%) diff --git a/node-test/README.md b/node-test/README.md index e4cf19b04..b7a67aeb5 100644 --- a/node-test/README.md +++ b/node-test/README.md @@ -3,8 +3,8 @@ Cursory test that 'xterm-core' works: ``` # From root of this repo npm run compile # Outputs to xterm-core -npx webpack --config core-webpack.config.js # Outputs to lib +npx webpack --config webpack.config.core.js # Outputs to lib cd node-test npm link ../lib/ node index.js -``` \ No newline at end of file +``` diff --git a/core-webpack.config.js b/webpack.config.core.js similarity index 100% rename from core-webpack.config.js rename to webpack.config.core.js From 71179512330199b530fa88bf74d93f22c5feceaf Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 15:52:27 -0700 Subject: [PATCH 028/164] Output headless to out/headless --- headless/headless/Terminal.d.ts | 28 - headless/headless/Terminal.d.ts.map | 1 - headless/headless/Terminal.js | 130 --- headless/headless/Terminal.js.map | 1 - headless/headless/public/Terminal.d.ts | 48 - headless/headless/public/Terminal.d.ts.map | 1 - headless/headless/public/Terminal.js | 147 --- headless/headless/public/Terminal.js.map | 1 - headless/headless/tsconfig.tsbuildinfo | 1120 -------------------- headless/headless/types.d.ts | 32 - headless/headless/types.d.ts.map | 1 - headless/headless/types.js | 3 - headless/headless/types.js.map | 1 - src/headless/tsconfig.json | 3 +- 14 files changed, 1 insertion(+), 1516 deletions(-) delete mode 100644 headless/headless/Terminal.d.ts delete mode 100644 headless/headless/Terminal.d.ts.map delete mode 100644 headless/headless/Terminal.js delete mode 100644 headless/headless/Terminal.js.map delete mode 100644 headless/headless/public/Terminal.d.ts delete mode 100644 headless/headless/public/Terminal.d.ts.map delete mode 100644 headless/headless/public/Terminal.js delete mode 100644 headless/headless/public/Terminal.js.map delete mode 100644 headless/headless/tsconfig.tsbuildinfo delete mode 100644 headless/headless/types.d.ts delete mode 100644 headless/headless/types.d.ts.map delete mode 100644 headless/headless/types.js delete mode 100644 headless/headless/types.js.map diff --git a/headless/headless/Terminal.d.ts b/headless/headless/Terminal.d.ts deleted file mode 100644 index 7ab11fc7b..000000000 --- a/headless/headless/Terminal.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { IBuffer } from 'common/buffer/Types'; -import { CoreTerminal } from 'common/CoreTerminal'; -import { IEvent } from 'common/EventEmitter'; -import { ITerminalOptions as IInitializedTerminalOptions } from 'common/services/Services'; -import { IMarker, ITerminalOptions } from 'common/Types'; -export declare class Terminal extends CoreTerminal { - get options(): IInitializedTerminalOptions; - private _onBell; - get onBell(): IEvent; - private _onCursorMove; - get onCursorMove(): IEvent; - private _onTitleChange; - get onTitleChange(): IEvent; - private _onA11yCharEmitter; - get onA11yChar(): IEvent; - private _onA11yTabEmitter; - get onA11yTab(): IEvent; - constructor(options?: ITerminalOptions); - dispose(): void; - get buffer(): IBuffer; - get markers(): IMarker[]; - addMarker(cursorYOffset: number): IMarker | undefined; - bell(): void; - resize(x: number, y: number): void; - clear(): void; - reset(): void; -} -//# sourceMappingURL=Terminal.d.ts.map \ No newline at end of file diff --git a/headless/headless/Terminal.d.ts.map b/headless/headless/Terminal.d.ts.map deleted file mode 100644 index f5020f835..000000000 --- a/headless/headless/Terminal.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Terminal.d.ts","sourceRoot":"","sources":["../../src/headless/Terminal.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAA8B,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,gBAAgB,IAAI,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC3F,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAgB,MAAM,cAAc,CAAC;AAEvE,qBAAa,QAAS,SAAQ,YAAY;IAExC,IAAW,OAAO,IAAI,2BAA2B,CAAwC;IAGzF,OAAO,CAAC,OAAO,CAA6B;IAC5C,IAAW,MAAM,IAAK,MAAM,CAAC,IAAI,CAAC,CAA+B;IACjE,OAAO,CAAC,aAAa,CAA4B;IACjD,IAAW,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,CAAqC;IAC5E,OAAO,CAAC,cAAc,CAA8B;IACpD,IAAW,aAAa,IAAI,MAAM,CAAC,MAAM,CAAC,CAAsC;IAEhF,OAAO,CAAC,kBAAkB,CAA8B;IACxD,IAAW,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,CAA0C;IACjF,OAAO,CAAC,iBAAiB,CAA8B;IACvD,IAAW,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,CAAyC;gBAe7E,OAAO,GAAE,gBAAqB;IAezB,OAAO,IAAI,IAAI;IAWtB,IAAW,MAAM,IAAI,OAAO,CAE3B;IAED,IAAW,OAAO,IAAI,OAAO,EAAE,CAE9B;IAEM,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IASrD,IAAI,IAAI,IAAI;IAUZ,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAWlC,KAAK,IAAI,IAAI;IAwBb,KAAK,IAAI,IAAI;CAWrB"} \ No newline at end of file diff --git a/headless/headless/Terminal.js b/headless/headless/Terminal.js deleted file mode 100644 index 66f4d3646..000000000 --- a/headless/headless/Terminal.js +++ /dev/null @@ -1,130 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Terminal = void 0; -var BufferLine_1 = require("common/buffer/BufferLine"); -var CoreTerminal_1 = require("common/CoreTerminal"); -var EventEmitter_1 = require("common/EventEmitter"); -var Terminal = (function (_super) { - __extends(Terminal, _super); - function Terminal(options) { - if (options === void 0) { options = {}; } - var _this = _super.call(this, options) || this; - _this._onBell = new EventEmitter_1.EventEmitter(); - _this._onCursorMove = new EventEmitter_1.EventEmitter(); - _this._onTitleChange = new EventEmitter_1.EventEmitter(); - _this._onA11yCharEmitter = new EventEmitter_1.EventEmitter(); - _this._onA11yTabEmitter = new EventEmitter_1.EventEmitter(); - _this._setup(); - _this.register(_this._inputHandler.onRequestBell(function () { return _this.bell(); })); - _this.register(_this._inputHandler.onRequestReset(function () { return _this.reset(); })); - _this.register(EventEmitter_1.forwardEvent(_this._inputHandler.onCursorMove, _this._onCursorMove)); - _this.register(EventEmitter_1.forwardEvent(_this._inputHandler.onTitleChange, _this._onTitleChange)); - _this.register(EventEmitter_1.forwardEvent(_this._inputHandler.onA11yChar, _this._onA11yCharEmitter)); - _this.register(EventEmitter_1.forwardEvent(_this._inputHandler.onA11yTab, _this._onA11yTabEmitter)); - return _this; - } - Object.defineProperty(Terminal.prototype, "options", { - get: function () { return this.optionsService.options; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "onBell", { - get: function () { return this._onBell.event; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "onCursorMove", { - get: function () { return this._onCursorMove.event; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "onTitleChange", { - get: function () { return this._onTitleChange.event; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "onA11yChar", { - get: function () { return this._onA11yCharEmitter.event; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "onA11yTab", { - get: function () { return this._onA11yTabEmitter.event; }, - enumerable: false, - configurable: true - }); - Terminal.prototype.dispose = function () { - if (this._isDisposed) { - return; - } - _super.prototype.dispose.call(this); - this.write = function () { }; - }; - Object.defineProperty(Terminal.prototype, "buffer", { - get: function () { - return this.buffers.active; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "markers", { - get: function () { - return this.buffer.markers; - }, - enumerable: false, - configurable: true - }); - Terminal.prototype.addMarker = function (cursorYOffset) { - if (this.buffer !== this.buffers.normal) { - return; - } - return this.buffer.addMarker(this.buffer.ybase + this.buffer.y + cursorYOffset); - }; - Terminal.prototype.bell = function () { - this._onBell.fire(); - }; - Terminal.prototype.resize = function (x, y) { - if (x === this.cols && y === this.rows) { - return; - } - _super.prototype.resize.call(this, x, y); - }; - Terminal.prototype.clear = function () { - if (this.buffer.ybase === 0 && this.buffer.y === 0) { - 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 (var i = 1; i < this.rows; i++) { - this.buffer.lines.push(this.buffer.getBlankLine(BufferLine_1.DEFAULT_ATTR_DATA)); - } - this._onScroll.fire({ position: this.buffer.ydisp, source: 0 }); - }; - Terminal.prototype.reset = function () { - this.options.rows = this.rows; - this.options.cols = this.cols; - this._setup(); - _super.prototype.reset.call(this); - }; - return Terminal; -}(CoreTerminal_1.CoreTerminal)); -exports.Terminal = Terminal; -//# sourceMappingURL=Terminal.js.map \ No newline at end of file diff --git a/headless/headless/Terminal.js.map b/headless/headless/Terminal.js.map deleted file mode 100644 index ba7e26dea..000000000 --- a/headless/headless/Terminal.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Terminal.js","sourceRoot":"","sources":["../../src/headless/Terminal.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAuBA,uDAA6D;AAE7D,oDAAmD;AACnD,oDAAyE;AAIzE;IAA8B,4BAAY;IA6BxC,kBACE,OAA8B;QAA9B,wBAAA,EAAA,YAA8B;QADhC,YAGE,kBAAM,OAAO,CAAC,SAWf;QAtCO,aAAO,GAAI,IAAI,2BAAY,EAAQ,CAAC;QAEpC,mBAAa,GAAG,IAAI,2BAAY,EAAQ,CAAC;QAEzC,oBAAc,GAAG,IAAI,2BAAY,EAAU,CAAC;QAG5C,wBAAkB,GAAG,IAAI,2BAAY,EAAU,CAAC;QAEhD,uBAAiB,GAAG,IAAI,2BAAY,EAAU,CAAC;QAoBrD,KAAI,CAAC,MAAM,EAAE,CAAC;QAGd,KAAI,CAAC,QAAQ,CAAC,KAAI,CAAC,aAAa,CAAC,aAAa,CAAC,cAAM,OAAA,KAAI,CAAC,IAAI,EAAE,EAAX,CAAW,CAAC,CAAC,CAAC;QACnE,KAAI,CAAC,QAAQ,CAAC,KAAI,CAAC,aAAa,CAAC,cAAc,CAAC,cAAM,OAAA,KAAI,CAAC,KAAK,EAAE,EAAZ,CAAY,CAAC,CAAC,CAAC;QACrE,KAAI,CAAC,QAAQ,CAAC,2BAAY,CAAC,KAAI,CAAC,aAAa,CAAC,YAAY,EAAE,KAAI,CAAC,aAAa,CAAC,CAAC,CAAC;QACjF,KAAI,CAAC,QAAQ,CAAC,2BAAY,CAAC,KAAI,CAAC,aAAa,CAAC,aAAa,EAAE,KAAI,CAAC,cAAc,CAAC,CAAC,CAAC;QACnF,KAAI,CAAC,QAAQ,CAAC,2BAAY,CAAC,KAAI,CAAC,aAAa,CAAC,UAAU,EAAE,KAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACpF,KAAI,CAAC,QAAQ,CAAC,2BAAY,CAAC,KAAI,CAAC,aAAa,CAAC,SAAS,EAAE,KAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;;IACpF,CAAC;IAzCD,sBAAW,6BAAO;aAAlB,cAAoD,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;;;OAAA;IAIzF,sBAAW,4BAAM;aAAjB,cAAqC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IAEjE,sBAAW,kCAAY;aAAvB,cAA0C,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IAE5E,sBAAW,mCAAa;aAAxB,cAA6C,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IAGhF,sBAAW,gCAAU;aAArB,cAA0C,OAAO,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IAEjF,sBAAW,+BAAS;aAApB,cAAyC,OAAO,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IA8BxE,0BAAO,GAAd;QACE,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,OAAO;SACR;QACD,iBAAM,OAAO,WAAE,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,cAAQ,CAAC,CAAC;IACzB,CAAC;IAKD,sBAAW,4BAAM;aAAjB;YACE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;QAC7B,CAAC;;;OAAA;IAED,sBAAW,6BAAO;aAAlB;YACE,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;QAC7B,CAAC;;;OAAA;IAEM,4BAAS,GAAhB,UAAiB,aAAqB;QAEpC,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACvC,OAAO;SACR;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC;IAClF,CAAC;IAEM,uBAAI,GAAX;QACE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;IAQM,yBAAM,GAAb,UAAc,CAAS,EAAE,CAAS;QAChC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE;YACtC,OAAO;SACR;QAED,iBAAM,MAAM,YAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACrB,CAAC;IAKM,wBAAK,GAAZ;QACE,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,EAAE;YAElD,OAAO;SACR;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC,CAAC;QACpF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;YAClC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,8BAAiB,CAAC,CAAC,CAAC;SACrE;QACD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAuB,EAAE,CAAC,CAAC;IACtF,CAAC;IAUM,wBAAK,GAAZ;QAKE,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAC9B,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAE9B,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,iBAAM,KAAK,WAAE,CAAC;IAChB,CAAC;IACH,eAAC;AAAD,CAAC,AAjID,CAA8B,2BAAY,GAiIzC;AAjIY,4BAAQ"} \ No newline at end of file diff --git a/headless/headless/public/Terminal.d.ts b/headless/headless/public/Terminal.d.ts deleted file mode 100644 index 669fff57f..000000000 --- a/headless/headless/public/Terminal.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { IEvent } from 'common/EventEmitter'; -import { IBufferNamespace as IBufferNamespaceApi, IMarker, IParser, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-core'; -export declare class Terminal implements ITerminalApi { - private _core; - private _parser; - private _buffer; - constructor(options?: ITerminalOptions); - private _checkProposedApi; - get onCursorMove(): IEvent; - get onLineFeed(): IEvent; - get onData(): IEvent; - get onBinary(): IEvent; - get onTitleChange(): IEvent; - get onResize(): IEvent<{ - cols: number; - rows: number; - }>; - get parser(): IParser; - get unicode(): IUnicodeHandling; - get rows(): number; - get cols(): number; - get buffer(): IBufferNamespaceApi; - get markers(): ReadonlyArray; - resize(columns: number, rows: number): void; - registerMarker(cursorYOffset: number): IMarker | undefined; - addMarker(cursorYOffset: number): IMarker | undefined; - dispose(): void; - clear(): void; - write(data: string | Uint8Array, callback?: () => void): void; - writeUtf8(data: Uint8Array, callback?: () => void): void; - writeln(data: string | Uint8Array, callback?: () => void): void; - getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string; - getOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell'): boolean; - getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number; - getOption(key: string): any; - setOption(key: 'bellSound' | 'fontFamily' | 'termName' | 'wordSeparator', value: string): void; - setOption(key: 'fontWeight' | 'fontWeightBold', value: 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void; - setOption(key: 'logLevel', value: 'debug' | 'info' | 'warn' | 'error' | 'off'): void; - setOption(key: 'bellStyle', value: 'none' | 'visual' | 'sound' | 'both'): void; - setOption(key: 'cursorStyle', value: 'block' | 'underline' | 'bar'): void; - setOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell', value: boolean): void; - setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void; - setOption(key: 'cols' | 'rows', value: number): void; - setOption(key: string, value: any): void; - reset(): void; - private _verifyIntegers; -} -//# sourceMappingURL=Terminal.d.ts.map \ No newline at end of file diff --git a/headless/headless/public/Terminal.d.ts.map b/headless/headless/public/Terminal.d.ts.map deleted file mode 100644 index b8fda9330..000000000 --- a/headless/headless/public/Terminal.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Terminal.d.ts","sourceRoot":"","sources":["../../../src/headless/public/Terminal.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAI7C,OAAO,EAAE,gBAAgB,IAAI,mBAAmB,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,YAAY,CAAC;AAGrJ,qBAAa,QAAS,YAAW,YAAY;IAC3C,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,OAAO,CAAiC;gBAEpC,OAAO,CAAC,EAAE,gBAAgB;IAItC,OAAO,CAAC,iBAAiB;IAMzB,IAAW,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,CAAoC;IAC3E,IAAW,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,CAAkC;IACvE,IAAW,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,CAA8B;IACjE,IAAW,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,CAAgC;IACrE,IAAW,aAAa,IAAI,MAAM,CAAC,MAAM,CAAC,CAAqC;IAC/E,IAAW,QAAQ,IAAI,MAAM,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAgC;IAE7F,IAAW,MAAM,IAAI,OAAO,CAM3B;IACD,IAAW,OAAO,IAAI,gBAAgB,CAGrC;IACD,IAAW,IAAI,IAAI,MAAM,CAA4B;IACrD,IAAW,IAAI,IAAI,MAAM,CAA4B;IACrD,IAAW,MAAM,IAAI,mBAAmB,CAMvC;IACD,IAAW,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,CAG3C;IACM,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAI3C,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAK1D,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAGrD,OAAO,IAAI,IAAI;IAGf,KAAK,IAAI,IAAI;IAGb,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI;IAG7D,SAAS,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI;IAGxD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI;IAI/D,SAAS,CAAC,GAAG,EAAE,WAAW,GAAG,WAAW,GAAG,aAAa,GAAG,YAAY,GAAG,UAAU,GAAG,cAAc,GAAG,UAAU,GAAG,eAAe,GAAG,MAAM;IAC7I,SAAS,CAAC,GAAG,EAAE,mBAAmB,GAAG,qBAAqB,GAAG,cAAc,GAAG,YAAY,GAAG,aAAa,GAAG,cAAc,GAAG,iBAAiB,GAAG,uBAAuB,GAAG,WAAW,GAAG,YAAY,GAAG,OAAO;IAChN,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,eAAe,GAAG,YAAY,GAAG,MAAM,GAAG,cAAc,GAAG,YAAY,GAAG,MAAM;IACrH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG;IAI3B,SAAS,CAAC,GAAG,EAAE,WAAW,GAAG,YAAY,GAAG,UAAU,GAAG,eAAe,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAC9F,SAAS,CAAC,GAAG,EAAE,YAAY,GAAG,gBAAgB,EAAE,KAAK,EAAE,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,IAAI;IAChK,SAAS,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,IAAI;IACpF,SAAS,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI;IAC9E,SAAS,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,KAAK,GAAG,IAAI;IACzE,SAAS,CAAC,GAAG,EAAE,mBAAmB,GAAG,qBAAqB,GAAG,cAAc,GAAG,YAAY,GAAG,aAAa,GAAG,cAAc,GAAG,iBAAiB,GAAG,uBAAuB,GAAG,WAAW,GAAG,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAC7N,SAAS,CAAC,GAAG,EAAE,UAAU,GAAG,eAAe,GAAG,YAAY,GAAG,cAAc,GAAG,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAChH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IACpD,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAIxC,KAAK,IAAI,IAAI;IAIpB,OAAO,CAAC,eAAe;CAOxB"} \ No newline at end of file diff --git a/headless/headless/public/Terminal.js b/headless/headless/public/Terminal.js deleted file mode 100644 index 1718c3b66..000000000 --- a/headless/headless/public/Terminal.js +++ /dev/null @@ -1,147 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Terminal = void 0; -var BufferNamespaceApi_1 = require("common/public/BufferNamespaceApi"); -var ParserApi_1 = require("common/public/ParserApi"); -var UnicodeApi_1 = require("common/public/UnicodeApi"); -var Terminal_1 = require("headless/Terminal"); -var Terminal = (function () { - function Terminal(options) { - this._core = new Terminal_1.Terminal(options); - } - Terminal.prototype._checkProposedApi = function () { - if (!this._core.optionsService.options.allowProposedApi) { - throw new Error('You must set the allowProposedApi option to true to use proposed API'); - } - }; - Object.defineProperty(Terminal.prototype, "onCursorMove", { - get: function () { return this._core.onCursorMove; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "onLineFeed", { - get: function () { return this._core.onLineFeed; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "onData", { - get: function () { return this._core.onData; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "onBinary", { - get: function () { return this._core.onBinary; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "onTitleChange", { - get: function () { return this._core.onTitleChange; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "onResize", { - get: function () { return this._core.onResize; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "parser", { - get: function () { - this._checkProposedApi(); - if (!this._parser) { - this._parser = new ParserApi_1.ParserApi(this._core); - } - return this._parser; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "unicode", { - get: function () { - this._checkProposedApi(); - return new UnicodeApi_1.UnicodeApi(this._core); - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "rows", { - get: function () { return this._core.rows; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "cols", { - get: function () { return this._core.cols; }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "buffer", { - get: function () { - this._checkProposedApi(); - if (!this._buffer) { - this._buffer = new BufferNamespaceApi_1.BufferNamespaceApi(this._core); - } - return this._buffer; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Terminal.prototype, "markers", { - get: function () { - this._checkProposedApi(); - return this._core.markers; - }, - enumerable: false, - configurable: true - }); - Terminal.prototype.resize = function (columns, rows) { - this._verifyIntegers(columns, rows); - this._core.resize(columns, rows); - }; - Terminal.prototype.registerMarker = function (cursorYOffset) { - this._checkProposedApi(); - this._verifyIntegers(cursorYOffset); - return this._core.addMarker(cursorYOffset); - }; - Terminal.prototype.addMarker = function (cursorYOffset) { - return this.registerMarker(cursorYOffset); - }; - Terminal.prototype.dispose = function () { - this._core.dispose(); - }; - Terminal.prototype.clear = function () { - this._core.clear(); - }; - Terminal.prototype.write = function (data, callback) { - this._core.write(data, callback); - }; - Terminal.prototype.writeUtf8 = function (data, callback) { - this._core.write(data, callback); - }; - Terminal.prototype.writeln = function (data, callback) { - this._core.write(data); - this._core.write('\r\n', callback); - }; - Terminal.prototype.getOption = function (key) { - return this._core.optionsService.getOption(key); - }; - Terminal.prototype.setOption = function (key, value) { - this._core.optionsService.setOption(key, value); - }; - Terminal.prototype.reset = function () { - this._core.reset(); - }; - Terminal.prototype._verifyIntegers = function () { - var values = []; - for (var _i = 0; _i < arguments.length; _i++) { - values[_i] = arguments[_i]; - } - for (var _a = 0, values_1 = values; _a < values_1.length; _a++) { - var value = values_1[_a]; - if (value === Infinity || isNaN(value) || value % 1 !== 0) { - throw new Error('This API only accepts integers'); - } - } - }; - return Terminal; -}()); -exports.Terminal = Terminal; -//# sourceMappingURL=Terminal.js.map \ No newline at end of file diff --git a/headless/headless/public/Terminal.js.map b/headless/headless/public/Terminal.js.map deleted file mode 100644 index 6e27bbc7d..000000000 --- a/headless/headless/public/Terminal.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Terminal.js","sourceRoot":"","sources":["../../../src/headless/public/Terminal.ts"],"names":[],"mappings":";;;AAMA,uEAAsE;AACtE,qDAAoD;AACpD,uDAAsD;AAEtD,8CAA6D;AAE7D;IAKE,kBAAY,OAA0B;QACpC,IAAI,CAAC,KAAK,GAAG,IAAI,mBAAY,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAEO,oCAAiB,GAAzB;QACE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,gBAAgB,EAAE;YACvD,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;SACzF;IACH,CAAC;IAED,sBAAW,kCAAY;aAAvB,cAA0C,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;;;OAAA;IAC3E,sBAAW,gCAAU;aAArB,cAAwC,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;;;OAAA;IACvE,sBAAW,4BAAM;aAAjB,cAAsC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;;;OAAA;IACjE,sBAAW,8BAAQ;aAAnB,cAAwC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;;;OAAA;IACrE,sBAAW,mCAAa;aAAxB,cAA6C,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;;;OAAA;IAC/E,sBAAW,8BAAQ;aAAnB,cAAgE,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;;;OAAA;IAE7F,sBAAW,4BAAM;aAAjB;YACE,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACjB,IAAI,CAAC,OAAO,GAAG,IAAI,qBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAC1C;YACD,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;;;OAAA;IACD,sBAAW,6BAAO;aAAlB;YACE,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzB,OAAO,IAAI,uBAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC;;;OAAA;IACD,sBAAW,0BAAI;aAAf,cAA4B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;;;OAAA;IACrD,sBAAW,0BAAI;aAAf,cAA4B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;;;OAAA;IACrD,sBAAW,4BAAM;aAAjB;YACE,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACjB,IAAI,CAAC,OAAO,GAAG,IAAI,uCAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACnD;YACD,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;;;OAAA;IACD,sBAAW,6BAAO;aAAlB;YACE,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;QAC5B,CAAC;;;OAAA;IACM,yBAAM,GAAb,UAAc,OAAe,EAAE,IAAY;QACzC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IACM,iCAAc,GAArB,UAAsB,aAAqB;QACzC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IAC7C,CAAC;IACM,4BAAS,GAAhB,UAAiB,aAAqB;QACpC,OAAO,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;IAC5C,CAAC;IACM,0BAAO,GAAd;QACE,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;IACM,wBAAK,GAAZ;QACE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IACM,wBAAK,GAAZ,UAAa,IAAyB,EAAE,QAAqB;QAC3D,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IACM,4BAAS,GAAhB,UAAiB,IAAgB,EAAE,QAAqB;QACtD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IACM,0BAAO,GAAd,UAAe,IAAyB,EAAE,QAAqB;QAC7D,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACrC,CAAC;IAKM,4BAAS,GAAhB,UAAiB,GAAQ;QACvB,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAClD,CAAC;IAUM,4BAAS,GAAhB,UAAiB,GAAQ,EAAE,KAAU;QACnC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAClD,CAAC;IACM,wBAAK,GAAZ;QACE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAEO,kCAAe,GAAvB;QAAwB,gBAAmB;aAAnB,UAAmB,EAAnB,qBAAmB,EAAnB,IAAmB;YAAnB,2BAAmB;;QACzC,KAAoB,UAAM,EAAN,iBAAM,EAAN,oBAAM,EAAN,IAAM,EAAE;YAAvB,IAAM,KAAK,eAAA;YACd,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,KAAK,CAAC,EAAE;gBACzD,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;aACnD;SACF;IACH,CAAC;IACH,eAAC;AAAD,CAAC,AAxGD,IAwGC;AAxGY,4BAAQ"} \ No newline at end of file diff --git a/headless/headless/tsconfig.tsbuildinfo b/headless/headless/tsconfig.tsbuildinfo deleted file mode 100644 index 7307c7473..000000000 --- a/headless/headless/tsconfig.tsbuildinfo +++ /dev/null @@ -1,1120 +0,0 @@ -{ - "program": { - "fileInfos": { - "../../node_modules/typescript/lib/lib.es5.d.ts": { - "version": "b3584bc5798ed422ce2516df360ffa9cf2d80b5eae852867db9ba3743145f895", - "signature": "b3584bc5798ed422ce2516df360ffa9cf2d80b5eae852867db9ba3743145f895", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2015.d.ts": { - "version": "dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6", - "signature": "dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6", - "affectsGlobalScope": false - }, - "../../node_modules/typescript/lib/lib.es2016.d.ts": { - "version": "7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467", - "signature": "7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467", - "affectsGlobalScope": false - }, - "../../node_modules/typescript/lib/lib.es2017.d.ts": { - "version": "8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9", - "signature": "8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9", - "affectsGlobalScope": false - }, - "../../node_modules/typescript/lib/lib.es2018.d.ts": { - "version": "5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06", - "signature": "5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06", - "affectsGlobalScope": false - }, - "../../node_modules/typescript/lib/lib.dom.d.ts": { - "version": "feeeb1dd8a80fb76be42b0426e8f3ffa9bdef3c2f3c12c147e7660b1c5ba8b3b", - "signature": "feeeb1dd8a80fb76be42b0426e8f3ffa9bdef3c2f3c12c147e7660b1c5ba8b3b", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2015.core.d.ts": { - "version": "46ee15e9fefa913333b61eaf6b18885900b139867d89832a515059b62cf16a17", - "signature": "46ee15e9fefa913333b61eaf6b18885900b139867d89832a515059b62cf16a17", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2015.collection.d.ts": { - "version": "43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c", - "signature": "43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2015.generator.d.ts": { - "version": "cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a", - "signature": "cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2015.iterable.d.ts": { - "version": "8b2a5df1ce95f78f6b74f1a555ccdb6baab0486b42d8345e0871dd82811f9b9a", - "signature": "8b2a5df1ce95f78f6b74f1a555ccdb6baab0486b42d8345e0871dd82811f9b9a", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2015.promise.d.ts": { - "version": "2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c", - "signature": "2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2015.proxy.d.ts": { - "version": "810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357", - "signature": "810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2015.reflect.d.ts": { - "version": "62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6", - "signature": "62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2015.symbol.d.ts": { - "version": "3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93", - "signature": "3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts": { - "version": "9d122b7e8c1a5c72506eea50c0973cba55b92b5532d5cafa8a6ce2c547d57551", - "signature": "9d122b7e8c1a5c72506eea50c0973cba55b92b5532d5cafa8a6ce2c547d57551", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2016.array.include.d.ts": { - "version": "3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006", - "signature": "3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2017.object.d.ts": { - "version": "17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a", - "signature": "17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts": { - "version": "7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98", - "signature": "7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2017.string.d.ts": { - "version": "6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577", - "signature": "6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2017.intl.d.ts": { - "version": "12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d", - "signature": "12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts": { - "version": "b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e", - "signature": "b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts": { - "version": "0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a", - "signature": "0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts": { - "version": "a40c4d82bf13fcded295ac29f354eb7d40249613c15e07b53f2fc75e45e16359", - "signature": "a40c4d82bf13fcded295ac29f354eb7d40249613c15e07b53f2fc75e45e16359", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2018.intl.d.ts": { - "version": "df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e", - "signature": "df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2018.promise.d.ts": { - "version": "bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c", - "signature": "bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2018.regexp.d.ts": { - "version": "c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8", - "signature": "c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.es2020.bigint.d.ts": { - "version": "7b5a10e3c897fabece5a51aa85b4111727d7adb53c2734b5d37230ff96802a09", - "signature": "7b5a10e3c897fabece5a51aa85b4111727d7adb53c2734b5d37230ff96802a09", - "affectsGlobalScope": true - }, - "../../node_modules/typescript/lib/lib.esnext.intl.d.ts": { - "version": "506b80b9951c9381dc5f11897b31fca5e2a65731d96ddefa19687fbc26b23c6e", - "signature": "506b80b9951c9381dc5f11897b31fca5e2a65731d96ddefa19687fbc26b23c6e", - "affectsGlobalScope": true - }, - "../../out/common/eventemitter.d.ts": { - "version": "5b03a7f7f7f551e3fe0e92da13d2e17e7ad7ee19c41d0637f4edbc120bc06f66", - "signature": "5b03a7f7f7f551e3fe0e92da13d2e17e7ad7ee19c41d0637f4edbc120bc06f66", - "affectsGlobalScope": false - }, - "../../out/common/circularlist.d.ts": { - "version": "f96222a7fe4af80068de748cd4bd0b247359b303c72cc827e887eaf6ef9fb758", - "signature": "f96222a7fe4af80068de748cd4bd0b247359b303c72cc827e887eaf6ef9fb758", - "affectsGlobalScope": false - }, - "../../out/common/parser/constants.d.ts": { - "version": "ae42446973a3c189ecac84723e74828ee292f9392935db874cb27ee19ca89093", - "signature": "ae42446973a3c189ecac84723e74828ee292f9392935db874cb27ee19ca89093", - "affectsGlobalScope": false - }, - "../../src/common/parser/types.d.ts": { - "version": "55b56377b6fa8b93856027f20ebaccd8e0c77d4327e45e45b5e2041cf94011cc", - "signature": "55b56377b6fa8b93856027f20ebaccd8e0c77d4327e45e45b5e2041cf94011cc", - "affectsGlobalScope": false - }, - "../../src/common/buffer/types.d.ts": { - "version": "5e2f59fc5cb1b39a2e163bafe30139a33dac4033edcb9b1b831d542abb7f7bae", - "signature": "5e2f59fc5cb1b39a2e163bafe30139a33dac4033edcb9b1b831d542abb7f7bae", - "affectsGlobalScope": false - }, - "../../out/common/services/services.d.ts": { - "version": "4672a4d6d71a25b4592922ecd70094e932348a031d39acc4cef027ea9b62cba0", - "signature": "4672a4d6d71a25b4592922ecd70094e932348a031d39acc4cef027ea9b62cba0", - "affectsGlobalScope": false - }, - "../../src/common/types.d.ts": { - "version": "d7d8eb9c47232c80348f2fc6c8eb7d3acb329b6d8fdcf1f1c38d6e5099f8370b", - "signature": "d7d8eb9c47232c80348f2fc6c8eb7d3acb329b6d8fdcf1f1c38d6e5099f8370b", - "affectsGlobalScope": false - }, - "../../out/common/buffer/constants.d.ts": { - "version": "ff74cff1b7fe399447fd661d0c68586e7b991d11d044af133963c04bde38a852", - "signature": "ff74cff1b7fe399447fd661d0c68586e7b991d11d044af133963c04bde38a852", - "affectsGlobalScope": false - }, - "../../out/common/buffer/attributedata.d.ts": { - "version": "421bb313e7b328ba640853d13b584fe7815b818bd02584d020a41b7a7120d262", - "signature": "421bb313e7b328ba640853d13b584fe7815b818bd02584d020a41b7a7120d262", - "affectsGlobalScope": false - }, - "../../out/common/buffer/bufferline.d.ts": { - "version": "baaa0fc61cb33a67caa0abb986740700be9313c6866ed78c17193e87ca7057a1", - "signature": "baaa0fc61cb33a67caa0abb986740700be9313c6866ed78c17193e87ca7057a1", - "affectsGlobalScope": false - }, - "../../out/common/lifecycle.d.ts": { - "version": "0ba457ac19650eb9dffb8216ca42947899613be5aee16f3809fe39187c30423e", - "signature": "0ba457ac19650eb9dffb8216ca42947899613be5aee16f3809fe39187c30423e", - "affectsGlobalScope": false - }, - "../../out/common/inputhandler.d.ts": { - "version": "542507ad71abebbfe8b5da8758e1aa47bfce3acd0da245f10885cab9934b71d6", - "signature": "542507ad71abebbfe8b5da8758e1aa47bfce3acd0da245f10885cab9934b71d6", - "affectsGlobalScope": false - }, - "../../out/common/coreterminal.d.ts": { - "version": "ab615cd4d0ef6f17d26eef27cdf5beec0e081e59b5eefb09ede878c2cabb4c15", - "signature": "ab615cd4d0ef6f17d26eef27cdf5beec0e081e59b5eefb09ede878c2cabb4c15", - "affectsGlobalScope": false - }, - "../../src/headless/terminal.ts": { - "version": "59209d1535dcfbe8bac847ccf13e829a9ea692ce58fdcb3ee3605791ae60b564", - "signature": "5311ffa92a616a0729010de20af2272185a8b65b51ac26a496326b3b32aad8cc", - "affectsGlobalScope": false - }, - "../../src/headless/types.d.ts": { - "version": "d51941b70feb73ac171f24e34f11de9be17d0c4f224da1a6ed39fe8c31ba6695", - "signature": "d51941b70feb73ac171f24e34f11de9be17d0c4f224da1a6ed39fe8c31ba6695", - "affectsGlobalScope": false - }, - "../../out/common/public/buffernamespaceapi.d.ts": { - "version": "1f8e93ce424bd436ad641d8313d849af586a3779adbfd870e1cfee72a212ae57", - "signature": "1f8e93ce424bd436ad641d8313d849af586a3779adbfd870e1cfee72a212ae57", - "affectsGlobalScope": false - }, - "../../out/common/public/parserapi.d.ts": { - "version": "7c0d242565ad3b41ef8666e46fbd88aec222d2e9b2a343ac315b00373401ffc2", - "signature": "7c0d242565ad3b41ef8666e46fbd88aec222d2e9b2a343ac315b00373401ffc2", - "affectsGlobalScope": false - }, - "../../out/common/public/unicodeapi.d.ts": { - "version": "d77b28e85c1bbc95897707b719c4797ac94f5bf76572c81baae195787133826c", - "signature": "d77b28e85c1bbc95897707b719c4797ac94f5bf76572c81baae195787133826c", - "affectsGlobalScope": false - }, - "../../src/headless/public/terminal.ts": { - "version": "fce93b9408e0c088a1c6802aff2cf8cc46ac0feddc59f26b5a3241d0f03c82db", - "signature": "503924e7f37322f587ebce5459da9c47860c843c0d30d6d09b6ba25d5d169ac7", - "affectsGlobalScope": false - }, - "../../typings/xterm.d.ts": { - "version": "d5256f76893350e4897436490570d291be7a2a005d44e3fa221f1a19804b8c5e", - "signature": "d5256f76893350e4897436490570d291be7a2a005d44e3fa221f1a19804b8c5e", - "affectsGlobalScope": false - }, - "../../typings/xterm-core.d.ts": { - "version": "675fd5779b700c3e864a36a14db728d91027632f90e60c7bfd440b5db61e174d", - "signature": "675fd5779b700c3e864a36a14db728d91027632f90e60c7bfd440b5db61e174d", - "affectsGlobalScope": false - }, - "../../node_modules/@types/mocha/index.d.ts": { - "version": "0359800d3b440f8515001431cde1500944e156040577425eb3f7b80af0846612", - "signature": "0359800d3b440f8515001431cde1500944e156040577425eb3f7b80af0846612", - "affectsGlobalScope": true - }, - "../../node_modules/@types/node/globals.d.ts": { - "version": "25b4a0c4fab47c373ee49df4c239826ee3430019fc0c1b5e59edc3e398b7468d", - "signature": "25b4a0c4fab47c373ee49df4c239826ee3430019fc0c1b5e59edc3e398b7468d", - "affectsGlobalScope": true - }, - "../../node_modules/@types/node/async_hooks.d.ts": { - "version": "c9e8a340da877b05a52525554aa255b3f44958c7f6748ebf5cbe0bfbe6766878", - "signature": "c9e8a340da877b05a52525554aa255b3f44958c7f6748ebf5cbe0bfbe6766878", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/buffer.d.ts": { - "version": "a473cf45c3d9809518f8af913312139d9f4db6887dc554e0d06d0f4e52722e6b", - "signature": "a473cf45c3d9809518f8af913312139d9f4db6887dc554e0d06d0f4e52722e6b", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/child_process.d.ts": { - "version": "a668dfae917097b30fc29bbebeeb869cee22529f2aa9976cea03c7e834a1b841", - "signature": "a668dfae917097b30fc29bbebeeb869cee22529f2aa9976cea03c7e834a1b841", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/cluster.d.ts": { - "version": "04eaa93bd75f937f9184dcb95a7983800c5770cf8ddd8ac0f3734dc02f5b20ef", - "signature": "04eaa93bd75f937f9184dcb95a7983800c5770cf8ddd8ac0f3734dc02f5b20ef", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/console.d.ts": { - "version": "c8155caf28fc7b0a564156a5df28ad8a844a3bd32d331d148d8f3ce88025c870", - "signature": "c8155caf28fc7b0a564156a5df28ad8a844a3bd32d331d148d8f3ce88025c870", - "affectsGlobalScope": true - }, - "../../node_modules/@types/node/constants.d.ts": { - "version": "45ac321f2e15d268fd74a90ddaa6467dcaaff2c5b13f95b4b85831520fb7a491", - "signature": "45ac321f2e15d268fd74a90ddaa6467dcaaff2c5b13f95b4b85831520fb7a491", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/crypto.d.ts": { - "version": "0084b54e281a37c75079f92ca20603d5731de063e7a425852b2907de4dd19932", - "signature": "0084b54e281a37c75079f92ca20603d5731de063e7a425852b2907de4dd19932", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/dgram.d.ts": { - "version": "797a9d37eb1f76143311c3f0a186ce5c0d8735e94c0ca08ff8712a876c9b4f9e", - "signature": "797a9d37eb1f76143311c3f0a186ce5c0d8735e94c0ca08ff8712a876c9b4f9e", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/dns.d.ts": { - "version": "bc31e01146eec89eb870b9ad8c55d759bcbc8989a894e6f0f81f832e0d10eb04", - "signature": "bc31e01146eec89eb870b9ad8c55d759bcbc8989a894e6f0f81f832e0d10eb04", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/domain.d.ts": { - "version": "2866a528b2708aa272ec3eaafd3c980abb23aec1ef831cfc5eb2186b98c37ce5", - "signature": "2866a528b2708aa272ec3eaafd3c980abb23aec1ef831cfc5eb2186b98c37ce5", - "affectsGlobalScope": true - }, - "../../node_modules/@types/node/events.d.ts": { - "version": "153d835dc32985120790e10102834b0a5bd979bb5e42bfbb33c0ff6260cf03ce", - "signature": "153d835dc32985120790e10102834b0a5bd979bb5e42bfbb33c0ff6260cf03ce", - "affectsGlobalScope": true - }, - "../../node_modules/@types/node/fs.d.ts": { - "version": "a44c87a409b60f211a240341905d818f5f173420dcf7f989ee6c8a1a3d812ae9", - "signature": "a44c87a409b60f211a240341905d818f5f173420dcf7f989ee6c8a1a3d812ae9", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/fs/promises.d.ts": { - "version": "bdaf554ae2d9d09e2a42f58a29ef7f80e5b5c1d7b96bfb717243dc91a477216e", - "signature": "bdaf554ae2d9d09e2a42f58a29ef7f80e5b5c1d7b96bfb717243dc91a477216e", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/http.d.ts": { - "version": "dce8672a79c7221c10a355b905940ab57505bc480a72a5da33ba24cbf82bb75c", - "signature": "dce8672a79c7221c10a355b905940ab57505bc480a72a5da33ba24cbf82bb75c", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/http2.d.ts": { - "version": "321ea733ae7f611077a2d7b4bc378ac4a6b7e365e1a51c71a7e5b2818e1e310a", - "signature": "321ea733ae7f611077a2d7b4bc378ac4a6b7e365e1a51c71a7e5b2818e1e310a", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/https.d.ts": { - "version": "13257840c0850d4ebd7c2b17604a9e006f752de76c2400ebc752bc465c330452", - "signature": "13257840c0850d4ebd7c2b17604a9e006f752de76c2400ebc752bc465c330452", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/inspector.d.ts": { - "version": "42176966283d3835c34278b9b5c0f470d484c0c0c6a55c20a2c916a1ce69b6e8", - "signature": "42176966283d3835c34278b9b5c0f470d484c0c0c6a55c20a2c916a1ce69b6e8", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/module.d.ts": { - "version": "0cff7901aedfe78e314f7d44088f07e2afa1b6e4f0473a4169b8456ca2fb245d", - "signature": "0cff7901aedfe78e314f7d44088f07e2afa1b6e4f0473a4169b8456ca2fb245d", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/net.d.ts": { - "version": "40b957b502b40dd490ee334aed47a30636f8d14a0267d1b6c088c2be1dcf2757", - "signature": "40b957b502b40dd490ee334aed47a30636f8d14a0267d1b6c088c2be1dcf2757", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/os.d.ts": { - "version": "69640cc2e76dad52daeb9914e6b70c5c9a5591a3a65190a2d3ea432cf0015e16", - "signature": "69640cc2e76dad52daeb9914e6b70c5c9a5591a3a65190a2d3ea432cf0015e16", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/path.d.ts": { - "version": "21e64a125f65dff99cc3ed366c96e922b90daed343eb52ecdace5f220401dcda", - "signature": "21e64a125f65dff99cc3ed366c96e922b90daed343eb52ecdace5f220401dcda", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/perf_hooks.d.ts": { - "version": "4982d94cb6427263c8839d8d6324a8bbe129e931deb61a7380f8fad17ba2cfc0", - "signature": "4982d94cb6427263c8839d8d6324a8bbe129e931deb61a7380f8fad17ba2cfc0", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/process.d.ts": { - "version": "b0b00cf2e8107ab671243a73d2fbd6296a853bebe3fcfaaca293f65aaa245eaf", - "signature": "b0b00cf2e8107ab671243a73d2fbd6296a853bebe3fcfaaca293f65aaa245eaf", - "affectsGlobalScope": true - }, - "../../node_modules/@types/node/punycode.d.ts": { - "version": "7f77304372efe3c9967e5f9ea2061f1b4bf41dc3cda3c83cdd676f2e5af6b7e6", - "signature": "7f77304372efe3c9967e5f9ea2061f1b4bf41dc3cda3c83cdd676f2e5af6b7e6", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/querystring.d.ts": { - "version": "992c6f6be16c0a1d2eec13ece33adeea2c747ba27fcd078353a8f4bb5b4fea58", - "signature": "992c6f6be16c0a1d2eec13ece33adeea2c747ba27fcd078353a8f4bb5b4fea58", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/readline.d.ts": { - "version": "3b790d08129aca55fd5ae1672d1d26594147ac0d5f2eedc30c7575eb18daef7e", - "signature": "3b790d08129aca55fd5ae1672d1d26594147ac0d5f2eedc30c7575eb18daef7e", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/repl.d.ts": { - "version": "64535caf208a02420d2d04eb2029269efedd11eb8597ada0d5e6f3d54ec663ae", - "signature": "64535caf208a02420d2d04eb2029269efedd11eb8597ada0d5e6f3d54ec663ae", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/stream.d.ts": { - "version": "e7b5a3f40f19d9eea71890c70dfb37ac5dd82cbffe5f95bc8f23c536455732d0", - "signature": "e7b5a3f40f19d9eea71890c70dfb37ac5dd82cbffe5f95bc8f23c536455732d0", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/string_decoder.d.ts": { - "version": "4fd3c4debadce3e9ab9dec3eb45f7f5e2e3d4ad65cf975a6d938d883cfb25a50", - "signature": "4fd3c4debadce3e9ab9dec3eb45f7f5e2e3d4ad65cf975a6d938d883cfb25a50", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/timers.d.ts": { - "version": "0953427f9c2498f71dd912fdd8a81b19cf6925de3e1ad67ab9a77b9a0f79bf0b", - "signature": "0953427f9c2498f71dd912fdd8a81b19cf6925de3e1ad67ab9a77b9a0f79bf0b", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/tls.d.ts": { - "version": "f89a6d56f0267f6e73c707f8a89d2f38e9928e10bfa505f39a4f4bf954093aee", - "signature": "f89a6d56f0267f6e73c707f8a89d2f38e9928e10bfa505f39a4f4bf954093aee", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/trace_events.d.ts": { - "version": "7df562288f949945cf69c21cd912100c2afedeeb7cdb219085f7f4b46cb7dde4", - "signature": "7df562288f949945cf69c21cd912100c2afedeeb7cdb219085f7f4b46cb7dde4", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/tty.d.ts": { - "version": "9d16690485ff1eb4f6fc57aebe237728fd8e03130c460919da3a35f4d9bd97f5", - "signature": "9d16690485ff1eb4f6fc57aebe237728fd8e03130c460919da3a35f4d9bd97f5", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/url.d.ts": { - "version": "dcc6910d95a3625fd2b0487fda055988e46ab46c357a1b3618c27b4a8dd739c9", - "signature": "dcc6910d95a3625fd2b0487fda055988e46ab46c357a1b3618c27b4a8dd739c9", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/util.d.ts": { - "version": "e649840284bab8c4d09cadc125cd7fbde7529690cc1a0881872b6a9cd202819b", - "signature": "e649840284bab8c4d09cadc125cd7fbde7529690cc1a0881872b6a9cd202819b", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/v8.d.ts": { - "version": "a364b4a8a015ae377052fa4fac94204d79a69d879567f444c7ceff1b7a18482d", - "signature": "a364b4a8a015ae377052fa4fac94204d79a69d879567f444c7ceff1b7a18482d", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/vm.d.ts": { - "version": "1aa7dbace2b7b2ef60897dcd4f66252ee6ba85e594ded8918c9acdcecda1896c", - "signature": "1aa7dbace2b7b2ef60897dcd4f66252ee6ba85e594ded8918c9acdcecda1896c", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/worker_threads.d.ts": { - "version": "6c63cb179eda2be5ab45dc146fa4151bec8ce4781986935fe40adfc69cbbf214", - "signature": "6c63cb179eda2be5ab45dc146fa4151bec8ce4781986935fe40adfc69cbbf214", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/zlib.d.ts": { - "version": "4926467de88a92a4fc9971d8c6f21b91eca1c0e7fc2a46cc4638ab9440c73875", - "signature": "4926467de88a92a4fc9971d8c6f21b91eca1c0e7fc2a46cc4638ab9440c73875", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/globals.global.d.ts": { - "version": "2708349d5a11a5c2e5f3a0765259ebe7ee00cdcc8161cb9990cb4910328442a1", - "signature": "2708349d5a11a5c2e5f3a0765259ebe7ee00cdcc8161cb9990cb4910328442a1", - "affectsGlobalScope": true - }, - "../../node_modules/@types/node/wasi.d.ts": { - "version": "4e0a4d84b15692ea8669fe4f3d05a4f204567906b1347da7a58b75f45bae48d3", - "signature": "4e0a4d84b15692ea8669fe4f3d05a4f204567906b1347da7a58b75f45bae48d3", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/ts3.6/base.d.ts": { - "version": "ae68a04912ee5a0f589276f9ec60b095f8c40d48128a4575b3fdd7d93806931c", - "signature": "ae68a04912ee5a0f589276f9ec60b095f8c40d48128a4575b3fdd7d93806931c", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/assert.d.ts": { - "version": "b3593bd345ebea5e4d0a894c03251a3774b34df3d6db57075c18e089a599ba76", - "signature": "b3593bd345ebea5e4d0a894c03251a3774b34df3d6db57075c18e089a599ba76", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/base.d.ts": { - "version": "e61a21e9418f279bc480394a94d1581b2dee73747adcbdef999b6737e34d721b", - "signature": "e61a21e9418f279bc480394a94d1581b2dee73747adcbdef999b6737e34d721b", - "affectsGlobalScope": false - }, - "../../node_modules/@types/node/index.d.ts": { - "version": "6c137dee82a61e14a1eb6a0ba56925b66fd83abf15acf72fe59a10b15e80e319", - "signature": "6c137dee82a61e14a1eb6a0ba56925b66fd83abf15acf72fe59a10b15e80e319", - "affectsGlobalScope": false - } - }, - "options": { - "target": 1, - "lib": [ - "lib.es2015.d.ts", - "lib.es2016.array.include.d.ts" - ], - "rootDir": "../../src", - "sourceMap": true, - "removeComments": true, - "pretty": true, - "incremental": true, - "experimentalDecorators": true, - "composite": true, - "strict": true, - "declarationMap": true, - "outDir": "..", - "types": [ - "../../node_modules/@types/mocha", - "../../node_modules/@types/node" - ], - "baseUrl": "../../src", - "extendedDiagnostics": true, - "paths": { - "common/*": [ - "./common/*" - ] - }, - "pathsBasePath": "D:/GitHub/Tyriar/xterm.js/src/headless", - "watch": true, - "preserveWatchOutput": true, - "configFilePath": "../../src/headless/tsconfig.json" - }, - "referencedMap": { - "../../node_modules/@types/node/base.d.ts": [ - "../../node_modules/@types/node/assert.d.ts", - "../../node_modules/@types/node/ts3.6/base.d.ts" - ], - "../../node_modules/@types/node/child_process.d.ts": [ - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/fs.d.ts", - "../../node_modules/@types/node/net.d.ts", - "../../node_modules/@types/node/stream.d.ts" - ], - "../../node_modules/@types/node/cluster.d.ts": [ - "../../node_modules/@types/node/child_process.d.ts", - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/net.d.ts" - ], - "../../node_modules/@types/node/console.d.ts": [ - "../../node_modules/@types/node/util.d.ts" - ], - "../../node_modules/@types/node/constants.d.ts": [ - "../../node_modules/@types/node/crypto.d.ts", - "../../node_modules/@types/node/fs.d.ts", - "../../node_modules/@types/node/os.d.ts" - ], - "../../node_modules/@types/node/crypto.d.ts": [ - "../../node_modules/@types/node/stream.d.ts" - ], - "../../node_modules/@types/node/dgram.d.ts": [ - "../../node_modules/@types/node/dns.d.ts", - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/net.d.ts" - ], - "../../node_modules/@types/node/domain.d.ts": [ - "../../node_modules/@types/node/events.d.ts" - ], - "../../node_modules/@types/node/events.d.ts": [ - "../../node_modules/@types/node/events.d.ts" - ], - "../../node_modules/@types/node/fs.d.ts": [ - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/fs/promises.d.ts", - "../../node_modules/@types/node/stream.d.ts", - "../../node_modules/@types/node/url.d.ts" - ], - "../../node_modules/@types/node/fs/promises.d.ts": [ - "../../node_modules/@types/node/fs.d.ts" - ], - "../../node_modules/@types/node/http.d.ts": [ - "../../node_modules/@types/node/net.d.ts", - "../../node_modules/@types/node/stream.d.ts", - "../../node_modules/@types/node/url.d.ts" - ], - "../../node_modules/@types/node/http2.d.ts": [ - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/fs.d.ts", - "../../node_modules/@types/node/http.d.ts", - "../../node_modules/@types/node/net.d.ts", - "../../node_modules/@types/node/stream.d.ts", - "../../node_modules/@types/node/tls.d.ts", - "../../node_modules/@types/node/url.d.ts" - ], - "../../node_modules/@types/node/https.d.ts": [ - "../../node_modules/@types/node/http.d.ts", - "../../node_modules/@types/node/tls.d.ts", - "../../node_modules/@types/node/url.d.ts" - ], - "../../node_modules/@types/node/index.d.ts": [ - "../../node_modules/@types/node/base.d.ts" - ], - "../../node_modules/@types/node/inspector.d.ts": [ - "../../node_modules/@types/node/events.d.ts" - ], - "../../node_modules/@types/node/module.d.ts": [ - "../../node_modules/@types/node/url.d.ts" - ], - "../../node_modules/@types/node/net.d.ts": [ - "../../node_modules/@types/node/dns.d.ts", - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/stream.d.ts" - ], - "../../node_modules/@types/node/perf_hooks.d.ts": [ - "../../node_modules/@types/node/async_hooks.d.ts" - ], - "../../node_modules/@types/node/process.d.ts": [ - "../../node_modules/@types/node/tty.d.ts" - ], - "../../node_modules/@types/node/readline.d.ts": [ - "../../node_modules/@types/node/events.d.ts" - ], - "../../node_modules/@types/node/repl.d.ts": [ - "../../node_modules/@types/node/readline.d.ts", - "../../node_modules/@types/node/util.d.ts", - "../../node_modules/@types/node/vm.d.ts" - ], - "../../node_modules/@types/node/stream.d.ts": [ - "../../node_modules/@types/node/events.d.ts" - ], - "../../node_modules/@types/node/tls.d.ts": [ - "../../node_modules/@types/node/net.d.ts" - ], - "../../node_modules/@types/node/ts3.6/base.d.ts": [ - "../../node_modules/@types/node/async_hooks.d.ts", - "../../node_modules/@types/node/buffer.d.ts", - "../../node_modules/@types/node/child_process.d.ts", - "../../node_modules/@types/node/cluster.d.ts", - "../../node_modules/@types/node/console.d.ts", - "../../node_modules/@types/node/constants.d.ts", - "../../node_modules/@types/node/crypto.d.ts", - "../../node_modules/@types/node/dgram.d.ts", - "../../node_modules/@types/node/dns.d.ts", - "../../node_modules/@types/node/domain.d.ts", - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/fs.d.ts", - "../../node_modules/@types/node/fs/promises.d.ts", - "../../node_modules/@types/node/globals.d.ts", - "../../node_modules/@types/node/globals.global.d.ts", - "../../node_modules/@types/node/http.d.ts", - "../../node_modules/@types/node/http2.d.ts", - "../../node_modules/@types/node/https.d.ts", - "../../node_modules/@types/node/inspector.d.ts", - "../../node_modules/@types/node/module.d.ts", - "../../node_modules/@types/node/net.d.ts", - "../../node_modules/@types/node/os.d.ts", - "../../node_modules/@types/node/path.d.ts", - "../../node_modules/@types/node/perf_hooks.d.ts", - "../../node_modules/@types/node/process.d.ts", - "../../node_modules/@types/node/punycode.d.ts", - "../../node_modules/@types/node/querystring.d.ts", - "../../node_modules/@types/node/readline.d.ts", - "../../node_modules/@types/node/repl.d.ts", - "../../node_modules/@types/node/stream.d.ts", - "../../node_modules/@types/node/string_decoder.d.ts", - "../../node_modules/@types/node/timers.d.ts", - "../../node_modules/@types/node/tls.d.ts", - "../../node_modules/@types/node/trace_events.d.ts", - "../../node_modules/@types/node/tty.d.ts", - "../../node_modules/@types/node/url.d.ts", - "../../node_modules/@types/node/util.d.ts", - "../../node_modules/@types/node/v8.d.ts", - "../../node_modules/@types/node/vm.d.ts", - "../../node_modules/@types/node/wasi.d.ts", - "../../node_modules/@types/node/worker_threads.d.ts", - "../../node_modules/@types/node/zlib.d.ts" - ], - "../../node_modules/@types/node/tty.d.ts": [ - "../../node_modules/@types/node/net.d.ts" - ], - "../../node_modules/@types/node/url.d.ts": [ - "../../node_modules/@types/node/querystring.d.ts" - ], - "../../node_modules/@types/node/v8.d.ts": [ - "../../node_modules/@types/node/stream.d.ts" - ], - "../../node_modules/@types/node/worker_threads.d.ts": [ - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/fs/promises.d.ts", - "../../node_modules/@types/node/stream.d.ts", - "../../node_modules/@types/node/url.d.ts", - "../../node_modules/@types/node/vm.d.ts" - ], - "../../node_modules/@types/node/zlib.d.ts": [ - "../../node_modules/@types/node/stream.d.ts" - ], - "../../out/common/buffer/attributedata.d.ts": [ - "../../out/common/buffer/constants.d.ts", - "../../src/common/types.d.ts" - ], - "../../out/common/buffer/bufferline.d.ts": [ - "../../out/common/buffer/attributedata.d.ts", - "../../src/common/types.d.ts" - ], - "../../out/common/circularlist.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../src/common/types.d.ts" - ], - "../../out/common/coreterminal.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../out/common/inputhandler.d.ts", - "../../out/common/lifecycle.d.ts", - "../../out/common/services/services.d.ts", - "../../src/common/buffer/types.d.ts", - "../../src/common/parser/types.d.ts", - "../../src/common/types.d.ts" - ], - "../../out/common/eventemitter.d.ts": [ - "../../src/common/types.d.ts" - ], - "../../out/common/inputhandler.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../out/common/lifecycle.d.ts", - "../../out/common/services/services.d.ts", - "../../src/common/parser/types.d.ts", - "../../src/common/types.d.ts" - ], - "../../out/common/lifecycle.d.ts": [ - "../../src/common/types.d.ts" - ], - "../../out/common/public/buffernamespaceapi.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../src/common/types.d.ts", - "../../typings/xterm.d.ts" - ], - "../../out/common/public/parserapi.d.ts": [ - "../../src/common/types.d.ts", - "../../typings/xterm.d.ts" - ], - "../../out/common/public/unicodeapi.d.ts": [ - "../../src/common/types.d.ts", - "../../typings/xterm.d.ts" - ], - "../../out/common/services/services.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../src/common/buffer/types.d.ts", - "../../src/common/types.d.ts" - ], - "../../src/common/buffer/types.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../src/common/types.d.ts" - ], - "../../src/common/parser/types.d.ts": [ - "../../out/common/parser/constants.d.ts", - "../../src/common/types.d.ts" - ], - "../../src/common/types.d.ts": [ - "../../out/common/circularlist.d.ts", - "../../out/common/eventemitter.d.ts", - "../../out/common/services/services.d.ts", - "../../src/common/buffer/types.d.ts", - "../../src/common/parser/types.d.ts", - "../../typings/xterm.d.ts" - ], - "../../src/headless/public/terminal.ts": [ - "../../out/common/eventemitter.d.ts", - "../../out/common/public/buffernamespaceapi.d.ts", - "../../out/common/public/parserapi.d.ts", - "../../out/common/public/unicodeapi.d.ts", - "../../src/headless/terminal.ts", - "../../typings/xterm-core.d.ts" - ], - "../../src/headless/terminal.ts": [ - "../../out/common/buffer/bufferline.d.ts", - "../../out/common/coreterminal.d.ts", - "../../out/common/eventemitter.d.ts", - "../../out/common/services/services.d.ts", - "../../src/common/buffer/types.d.ts", - "../../src/common/types.d.ts" - ], - "../../src/headless/types.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../src/common/buffer/types.d.ts", - "../../src/common/parser/types.d.ts", - "../../src/common/types.d.ts" - ] - }, - "exportedModulesMap": { - "../../node_modules/@types/node/base.d.ts": [ - "../../node_modules/@types/node/assert.d.ts", - "../../node_modules/@types/node/ts3.6/base.d.ts" - ], - "../../node_modules/@types/node/child_process.d.ts": [ - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/fs.d.ts", - "../../node_modules/@types/node/net.d.ts", - "../../node_modules/@types/node/stream.d.ts" - ], - "../../node_modules/@types/node/cluster.d.ts": [ - "../../node_modules/@types/node/child_process.d.ts", - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/net.d.ts" - ], - "../../node_modules/@types/node/console.d.ts": [ - "../../node_modules/@types/node/util.d.ts" - ], - "../../node_modules/@types/node/constants.d.ts": [ - "../../node_modules/@types/node/crypto.d.ts", - "../../node_modules/@types/node/fs.d.ts", - "../../node_modules/@types/node/os.d.ts" - ], - "../../node_modules/@types/node/crypto.d.ts": [ - "../../node_modules/@types/node/stream.d.ts" - ], - "../../node_modules/@types/node/dgram.d.ts": [ - "../../node_modules/@types/node/dns.d.ts", - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/net.d.ts" - ], - "../../node_modules/@types/node/domain.d.ts": [ - "../../node_modules/@types/node/events.d.ts" - ], - "../../node_modules/@types/node/events.d.ts": [ - "../../node_modules/@types/node/events.d.ts" - ], - "../../node_modules/@types/node/fs.d.ts": [ - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/fs/promises.d.ts", - "../../node_modules/@types/node/stream.d.ts", - "../../node_modules/@types/node/url.d.ts" - ], - "../../node_modules/@types/node/fs/promises.d.ts": [ - "../../node_modules/@types/node/fs.d.ts" - ], - "../../node_modules/@types/node/http.d.ts": [ - "../../node_modules/@types/node/net.d.ts", - "../../node_modules/@types/node/stream.d.ts", - "../../node_modules/@types/node/url.d.ts" - ], - "../../node_modules/@types/node/http2.d.ts": [ - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/fs.d.ts", - "../../node_modules/@types/node/http.d.ts", - "../../node_modules/@types/node/net.d.ts", - "../../node_modules/@types/node/stream.d.ts", - "../../node_modules/@types/node/tls.d.ts", - "../../node_modules/@types/node/url.d.ts" - ], - "../../node_modules/@types/node/https.d.ts": [ - "../../node_modules/@types/node/http.d.ts", - "../../node_modules/@types/node/tls.d.ts", - "../../node_modules/@types/node/url.d.ts" - ], - "../../node_modules/@types/node/index.d.ts": [ - "../../node_modules/@types/node/base.d.ts" - ], - "../../node_modules/@types/node/inspector.d.ts": [ - "../../node_modules/@types/node/events.d.ts" - ], - "../../node_modules/@types/node/module.d.ts": [ - "../../node_modules/@types/node/url.d.ts" - ], - "../../node_modules/@types/node/net.d.ts": [ - "../../node_modules/@types/node/dns.d.ts", - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/stream.d.ts" - ], - "../../node_modules/@types/node/perf_hooks.d.ts": [ - "../../node_modules/@types/node/async_hooks.d.ts" - ], - "../../node_modules/@types/node/process.d.ts": [ - "../../node_modules/@types/node/tty.d.ts" - ], - "../../node_modules/@types/node/readline.d.ts": [ - "../../node_modules/@types/node/events.d.ts" - ], - "../../node_modules/@types/node/repl.d.ts": [ - "../../node_modules/@types/node/readline.d.ts", - "../../node_modules/@types/node/util.d.ts", - "../../node_modules/@types/node/vm.d.ts" - ], - "../../node_modules/@types/node/stream.d.ts": [ - "../../node_modules/@types/node/events.d.ts" - ], - "../../node_modules/@types/node/tls.d.ts": [ - "../../node_modules/@types/node/net.d.ts" - ], - "../../node_modules/@types/node/ts3.6/base.d.ts": [ - "../../node_modules/@types/node/async_hooks.d.ts", - "../../node_modules/@types/node/buffer.d.ts", - "../../node_modules/@types/node/child_process.d.ts", - "../../node_modules/@types/node/cluster.d.ts", - "../../node_modules/@types/node/console.d.ts", - "../../node_modules/@types/node/constants.d.ts", - "../../node_modules/@types/node/crypto.d.ts", - "../../node_modules/@types/node/dgram.d.ts", - "../../node_modules/@types/node/dns.d.ts", - "../../node_modules/@types/node/domain.d.ts", - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/fs.d.ts", - "../../node_modules/@types/node/fs/promises.d.ts", - "../../node_modules/@types/node/globals.d.ts", - "../../node_modules/@types/node/globals.global.d.ts", - "../../node_modules/@types/node/http.d.ts", - "../../node_modules/@types/node/http2.d.ts", - "../../node_modules/@types/node/https.d.ts", - "../../node_modules/@types/node/inspector.d.ts", - "../../node_modules/@types/node/module.d.ts", - "../../node_modules/@types/node/net.d.ts", - "../../node_modules/@types/node/os.d.ts", - "../../node_modules/@types/node/path.d.ts", - "../../node_modules/@types/node/perf_hooks.d.ts", - "../../node_modules/@types/node/process.d.ts", - "../../node_modules/@types/node/punycode.d.ts", - "../../node_modules/@types/node/querystring.d.ts", - "../../node_modules/@types/node/readline.d.ts", - "../../node_modules/@types/node/repl.d.ts", - "../../node_modules/@types/node/stream.d.ts", - "../../node_modules/@types/node/string_decoder.d.ts", - "../../node_modules/@types/node/timers.d.ts", - "../../node_modules/@types/node/tls.d.ts", - "../../node_modules/@types/node/trace_events.d.ts", - "../../node_modules/@types/node/tty.d.ts", - "../../node_modules/@types/node/url.d.ts", - "../../node_modules/@types/node/util.d.ts", - "../../node_modules/@types/node/v8.d.ts", - "../../node_modules/@types/node/vm.d.ts", - "../../node_modules/@types/node/wasi.d.ts", - "../../node_modules/@types/node/worker_threads.d.ts", - "../../node_modules/@types/node/zlib.d.ts" - ], - "../../node_modules/@types/node/tty.d.ts": [ - "../../node_modules/@types/node/net.d.ts" - ], - "../../node_modules/@types/node/url.d.ts": [ - "../../node_modules/@types/node/querystring.d.ts" - ], - "../../node_modules/@types/node/v8.d.ts": [ - "../../node_modules/@types/node/stream.d.ts" - ], - "../../node_modules/@types/node/worker_threads.d.ts": [ - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/fs/promises.d.ts", - "../../node_modules/@types/node/stream.d.ts", - "../../node_modules/@types/node/url.d.ts", - "../../node_modules/@types/node/vm.d.ts" - ], - "../../node_modules/@types/node/zlib.d.ts": [ - "../../node_modules/@types/node/stream.d.ts" - ], - "../../out/common/buffer/attributedata.d.ts": [ - "../../out/common/buffer/constants.d.ts", - "../../src/common/types.d.ts" - ], - "../../out/common/buffer/bufferline.d.ts": [ - "../../out/common/buffer/attributedata.d.ts", - "../../src/common/types.d.ts" - ], - "../../out/common/circularlist.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../src/common/types.d.ts" - ], - "../../out/common/coreterminal.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../out/common/inputhandler.d.ts", - "../../out/common/lifecycle.d.ts", - "../../out/common/services/services.d.ts", - "../../src/common/buffer/types.d.ts", - "../../src/common/parser/types.d.ts", - "../../src/common/types.d.ts" - ], - "../../out/common/eventemitter.d.ts": [ - "../../src/common/types.d.ts" - ], - "../../out/common/inputhandler.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../out/common/lifecycle.d.ts", - "../../out/common/services/services.d.ts", - "../../src/common/parser/types.d.ts", - "../../src/common/types.d.ts" - ], - "../../out/common/lifecycle.d.ts": [ - "../../src/common/types.d.ts" - ], - "../../out/common/public/buffernamespaceapi.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../src/common/types.d.ts", - "../../typings/xterm.d.ts" - ], - "../../out/common/public/parserapi.d.ts": [ - "../../src/common/types.d.ts", - "../../typings/xterm.d.ts" - ], - "../../out/common/public/unicodeapi.d.ts": [ - "../../src/common/types.d.ts", - "../../typings/xterm.d.ts" - ], - "../../out/common/services/services.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../src/common/buffer/types.d.ts", - "../../src/common/types.d.ts" - ], - "../../src/common/buffer/types.d.ts": [ - "../../src/common/eventemitter.ts", - "../../src/common/types.d.ts" - ], - "../../src/common/parser/types.d.ts": [ - "../../src/common/parser/constants.ts", - "../../src/common/types.d.ts" - ], - "../../src/common/types.d.ts": [ - "../../src/common/buffer/types.d.ts", - "../../src/common/circularlist.ts", - "../../src/common/eventemitter.ts", - "../../src/common/parser/types.d.ts", - "../../src/common/services/services.ts", - "../../typings/xterm.d.ts" - ], - "../../src/headless/public/terminal.ts": [ - "../../out/common/eventemitter.d.ts", - "../../typings/xterm-core.d.ts" - ], - "../../src/headless/terminal.ts": [ - "../../out/common/coreterminal.d.ts", - "../../out/common/eventemitter.d.ts", - "../../out/common/services/services.d.ts", - "../../src/common/buffer/types.d.ts", - "../../src/common/types.d.ts" - ], - "../../src/headless/types.d.ts": [ - "../../out/common/eventemitter.d.ts", - "../../src/common/buffer/types.d.ts", - "../../src/common/parser/types.d.ts", - "../../src/common/types.d.ts" - ] - }, - "semanticDiagnosticsPerFile": [ - "../../node_modules/@types/mocha/index.d.ts", - "../../node_modules/@types/node/assert.d.ts", - "../../node_modules/@types/node/async_hooks.d.ts", - "../../node_modules/@types/node/base.d.ts", - "../../node_modules/@types/node/buffer.d.ts", - "../../node_modules/@types/node/child_process.d.ts", - "../../node_modules/@types/node/cluster.d.ts", - "../../node_modules/@types/node/console.d.ts", - "../../node_modules/@types/node/constants.d.ts", - "../../node_modules/@types/node/crypto.d.ts", - "../../node_modules/@types/node/dgram.d.ts", - "../../node_modules/@types/node/dns.d.ts", - "../../node_modules/@types/node/domain.d.ts", - "../../node_modules/@types/node/events.d.ts", - "../../node_modules/@types/node/fs.d.ts", - "../../node_modules/@types/node/fs/promises.d.ts", - "../../node_modules/@types/node/globals.d.ts", - "../../node_modules/@types/node/globals.global.d.ts", - "../../node_modules/@types/node/http.d.ts", - "../../node_modules/@types/node/http2.d.ts", - "../../node_modules/@types/node/https.d.ts", - "../../node_modules/@types/node/index.d.ts", - "../../node_modules/@types/node/inspector.d.ts", - "../../node_modules/@types/node/module.d.ts", - "../../node_modules/@types/node/net.d.ts", - "../../node_modules/@types/node/os.d.ts", - "../../node_modules/@types/node/path.d.ts", - "../../node_modules/@types/node/perf_hooks.d.ts", - "../../node_modules/@types/node/process.d.ts", - "../../node_modules/@types/node/punycode.d.ts", - "../../node_modules/@types/node/querystring.d.ts", - "../../node_modules/@types/node/readline.d.ts", - "../../node_modules/@types/node/repl.d.ts", - "../../node_modules/@types/node/stream.d.ts", - "../../node_modules/@types/node/string_decoder.d.ts", - "../../node_modules/@types/node/timers.d.ts", - "../../node_modules/@types/node/tls.d.ts", - "../../node_modules/@types/node/trace_events.d.ts", - "../../node_modules/@types/node/ts3.6/base.d.ts", - "../../node_modules/@types/node/tty.d.ts", - "../../node_modules/@types/node/url.d.ts", - "../../node_modules/@types/node/util.d.ts", - "../../node_modules/@types/node/v8.d.ts", - "../../node_modules/@types/node/vm.d.ts", - "../../node_modules/@types/node/wasi.d.ts", - "../../node_modules/@types/node/worker_threads.d.ts", - "../../node_modules/@types/node/zlib.d.ts", - "../../node_modules/typescript/lib/lib.dom.d.ts", - "../../node_modules/typescript/lib/lib.es2015.collection.d.ts", - "../../node_modules/typescript/lib/lib.es2015.core.d.ts", - "../../node_modules/typescript/lib/lib.es2015.d.ts", - "../../node_modules/typescript/lib/lib.es2015.generator.d.ts", - "../../node_modules/typescript/lib/lib.es2015.iterable.d.ts", - "../../node_modules/typescript/lib/lib.es2015.promise.d.ts", - "../../node_modules/typescript/lib/lib.es2015.proxy.d.ts", - "../../node_modules/typescript/lib/lib.es2015.reflect.d.ts", - "../../node_modules/typescript/lib/lib.es2015.symbol.d.ts", - "../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts", - "../../node_modules/typescript/lib/lib.es2016.array.include.d.ts", - "../../node_modules/typescript/lib/lib.es2016.d.ts", - "../../node_modules/typescript/lib/lib.es2017.d.ts", - "../../node_modules/typescript/lib/lib.es2017.intl.d.ts", - "../../node_modules/typescript/lib/lib.es2017.object.d.ts", - "../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts", - "../../node_modules/typescript/lib/lib.es2017.string.d.ts", - "../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts", - "../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts", - "../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts", - "../../node_modules/typescript/lib/lib.es2018.d.ts", - "../../node_modules/typescript/lib/lib.es2018.intl.d.ts", - "../../node_modules/typescript/lib/lib.es2018.promise.d.ts", - "../../node_modules/typescript/lib/lib.es2018.regexp.d.ts", - "../../node_modules/typescript/lib/lib.es2020.bigint.d.ts", - "../../node_modules/typescript/lib/lib.es5.d.ts", - "../../node_modules/typescript/lib/lib.esnext.intl.d.ts", - "../../out/common/buffer/attributedata.d.ts", - "../../out/common/buffer/bufferline.d.ts", - "../../out/common/buffer/constants.d.ts", - "../../out/common/circularlist.d.ts", - "../../out/common/coreterminal.d.ts", - "../../out/common/eventemitter.d.ts", - "../../out/common/inputhandler.d.ts", - "../../out/common/lifecycle.d.ts", - "../../out/common/parser/constants.d.ts", - "../../out/common/public/buffernamespaceapi.d.ts", - "../../out/common/public/parserapi.d.ts", - "../../out/common/public/unicodeapi.d.ts", - "../../out/common/services/services.d.ts", - "../../src/common/buffer/types.d.ts", - "../../src/common/parser/types.d.ts", - "../../src/common/types.d.ts", - "../../src/headless/public/terminal.ts", - "../../src/headless/terminal.ts", - "../../src/headless/types.d.ts", - "../../typings/xterm-core.d.ts", - "../../typings/xterm.d.ts" - ] - }, - "version": "4.2.4" -} \ No newline at end of file diff --git a/headless/headless/types.d.ts b/headless/headless/types.d.ts deleted file mode 100644 index a35f39887..000000000 --- a/headless/headless/types.d.ts +++ /dev/null @@ -1,32 +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[]; - options: ITerminalOptions; - onCursorMove: IEvent; - onData: IEvent; - onBinary: IEvent; - onLineFeed: IEvent; - onResize: IEvent<{ - cols: number; - rows: number; - }>; - onTitleChange: IEvent; - 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; -} -//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/headless/headless/types.d.ts.map b/headless/headless/types.d.ts.map deleted file mode 100644 index 7410b0435..000000000 --- a/headless/headless/types.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/headless/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErF,MAAM,WAAW,SAAU,SAAQ,aAAa;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,UAAU,CAAC;IACpB,OAAO,EAAE,OAAO,EAAE,CAAC;IAEnB,OAAO,EAAE,gBAAgB,CAAC;IAE1B,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9B,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5C,aAAa,CAAC,EAAE,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,GAAG,WAAW,CAAC;IAC5F,aAAa,CAAC,EAAE,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,GAAG,WAAW,CAAC;IACzG,aAAa,CAAC,EAAE,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,OAAO,GAAG,WAAW,CAAC;IAC7E,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,WAAW,CAAC;IAC/E,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IACtD,OAAO,IAAI,IAAI,CAAC;IAChB,KAAK,IAAI,IAAI,CAAC;IACd,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAC9D,KAAK,IAAI,IAAI,CAAC;CACf"} \ No newline at end of file diff --git a/headless/headless/types.js b/headless/headless/types.js deleted file mode 100644 index 11e638d1e..000000000 --- a/headless/headless/types.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/headless/headless/types.js.map b/headless/headless/types.js.map deleted file mode 100644 index d651a6aa4..000000000 --- a/headless/headless/types.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/headless/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/src/headless/tsconfig.json b/src/headless/tsconfig.json index 268bdbdd3..39f71bdaf 100644 --- a/src/headless/tsconfig.json +++ b/src/headless/tsconfig.json @@ -5,13 +5,12 @@ "es2015", "es2016.Array.Include" ], - "outDir": "../../headless", // Temporary outdir to avoid collisions with 'xterm' + "outDir": "../../out/headless", // Temporary outdir to avoid collisions with 'xterm' "types": [ "../../node_modules/@types/mocha", "../../node_modules/@types/node" ], "baseUrl": "../", - "extendedDiagnostics": true, "paths": { "common/*": [ "./common/*" ] } From 9b2e511bcb911e678ddd57963d5342ac62d944b2 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 15:57:21 -0700 Subject: [PATCH 029/164] Fix webpack headless --- .gitignore | 1 + node-test/README.md | 4 ++-- src/headless/tsconfig.json | 2 +- webpack.config.headless.js | 41 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 webpack.config.headless.js diff --git a/.gitignore b/.gitignore index 8aea04b2e..4958559ee 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ node_modules/ *.swp .lock-wscript lib/ +lib-headless/ out/ out-test/ .nyc_output/ diff --git a/node-test/README.md b/node-test/README.md index b7a67aeb5..0da501461 100644 --- a/node-test/README.md +++ b/node-test/README.md @@ -2,8 +2,8 @@ Cursory test that 'xterm-core' works: ``` # From root of this repo -npm run compile # Outputs to xterm-core -npx webpack --config webpack.config.core.js # Outputs to lib +npm run compile # Outputs to out/headless +npx webpack --config webpack.config.headless.js # Outputs to lib cd node-test npm link ../lib/ node index.js diff --git a/src/headless/tsconfig.json b/src/headless/tsconfig.json index 39f71bdaf..6085a07f2 100644 --- a/src/headless/tsconfig.json +++ b/src/headless/tsconfig.json @@ -5,7 +5,7 @@ "es2015", "es2016.Array.Include" ], - "outDir": "../../out/headless", // Temporary outdir to avoid collisions with 'xterm' + "outDir": "../../out", "types": [ "../../node_modules/@types/mocha", "../../node_modules/@types/node" diff --git a/webpack.config.headless.js b/webpack.config.headless.js new file mode 100644 index 000000000..2010e1905 --- /dev/null +++ b/webpack.config.headless.js @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2019 The xterm.js authors. All rights reserved. + * @license MIT + */ + +const path = require('path'); + +/** + * This webpack config does a production build for xterm.js. It works by taking the output from tsc + * (via `yarn watch` or `yarn prebuild`) which are put into `out/` and webpacks them into a + * production mode umd library module in `lib/`. The aliases are used fix up the absolute paths + * output by tsc (because of `baseUrl` and `paths` in `tsconfig.json`. + */ +module.exports = { + entry: './out/headless/public/Terminal.js', + devtool: 'source-map', + module: { + rules: [ + { + test: /\.js$/, + use: ["source-map-loader"], + enforce: "pre", + exclude: /node_modules/ + } + ] + }, + resolve: { + modules: ['./node_modules'], + extensions: [ '.js' ], + alias: { + common: path.resolve('./out/common'), + headless: path.resolve('./out/headless') + } + }, + output: { + filename: 'xterm.js', + path: path.resolve('./lib-headless'), + libraryTarget: 'umd' + }, + mode: 'production' +}; From 2191d1a16aece69d507e1048a530d5301e54e807 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 16:01:20 -0700 Subject: [PATCH 030/164] Output commonjs for headless --- webpack.config.headless.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/webpack.config.headless.js b/webpack.config.headless.js index 2010e1905..7ae666761 100644 --- a/webpack.config.headless.js +++ b/webpack.config.headless.js @@ -35,7 +35,9 @@ module.exports = { output: { filename: 'xterm.js', path: path.resolve('./lib-headless'), - libraryTarget: 'umd' + library: { + type: 'commonjs' + } }, mode: 'production' }; From 01babd149120ec46e0721e60b7d09dc31099bd3f Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 16:11:56 -0700 Subject: [PATCH 031/164] Do a pass of headless/Terminal members --- src/browser/Terminal.ts | 4 ++-- src/headless/Terminal.ts | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 5aed701ad..004f23147 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -113,8 +113,8 @@ export class Terminal extends CoreTerminal implements ITerminal { public get onSelectionChange(): IEvent { return this._onSelectionChange.event; } private _onTitleChange = new EventEmitter(); public get onTitleChange(): IEvent { return this._onTitleChange.event; } - private _onBell = new EventEmitter(); - public get onBell (): IEvent { return this._onBell.event; } + private _onBell = new EventEmitter(); + public get onBell(): IEvent { return this._onBell.event; } private _onFocus = new EventEmitter(); public get onFocus(): IEvent { return this._onFocus.event; } diff --git a/src/headless/Terminal.ts b/src/headless/Terminal.ts index 4011adb93..7f138ce1d 100644 --- a/src/headless/Terminal.ts +++ b/src/headless/Terminal.ts @@ -32,9 +32,8 @@ 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(); - public get onBell (): IEvent { return this._onBell.event; } + private _onBell = new EventEmitter(); + public get onBell(): IEvent { return this._onBell.event; } private _onCursorMove = new EventEmitter(); public get onCursorMove(): IEvent { return this._onCursorMove.event; } private _onTitleChange = new EventEmitter(); @@ -88,6 +87,17 @@ export class Terminal extends CoreTerminal { 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; } From 40992a7f76d1732c0bf67b7ad3f7e579aad385b3 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 16:18:07 -0700 Subject: [PATCH 032/164] Update node test --- node-test/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/node-test/index.js b/node-test/index.js index 19bff5dc4..7be332beb 100644 --- a/node-test/index.js +++ b/node-test/index.js @@ -1,12 +1,12 @@ import { createRequire } from 'module'; const require = createRequire(import.meta.url); -const xterm = require('xterm-core'); +const Terminal = require('../lib-headless/xterm.js').Terminal; console.log('Creating xterm-core terminal...'); -const terminal = new xterm.Terminal(); +const terminal = new Terminal(); console.log('Writing `ls` to terminal...') -terminal.write('ls', () => { +terminal.write('foo \x1b[1;31mbar\x1b[0m baz', () => { const bufferLine = terminal.buffer.normal.getLine(terminal.buffer.normal.cursorY); - const contents = bufferLine.translateToString(); - console.log(`Contents of terminal active buffer are: ${contents}`); // ls + const contents = bufferLine.translateToString(true); + console.log(`Contents of terminal active buffer are: ${contents}`); // foo bar baz }); From a6e6c07a3c2983535389f971ff9102f2764cbdc7 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 22 Jul 2021 16:23:04 -0700 Subject: [PATCH 033/164] Add first headless test --- node-test/index.js | 2 +- src/headless/Terminal.test.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/headless/Terminal.test.ts diff --git a/node-test/index.js b/node-test/index.js index 7be332beb..2fd8da7f9 100644 --- a/node-test/index.js +++ b/node-test/index.js @@ -4,7 +4,7 @@ const Terminal = require('../lib-headless/xterm.js').Terminal; console.log('Creating xterm-core terminal...'); const terminal = new Terminal(); -console.log('Writing `ls` to terminal...') +console.log('Writing to terminal...') terminal.write('foo \x1b[1;31mbar\x1b[0m baz', () => { const bufferLine = terminal.buffer.normal.getLine(terminal.buffer.normal.cursorY); const contents = bufferLine.translateToString(true); diff --git a/src/headless/Terminal.test.ts b/src/headless/Terminal.test.ts new file mode 100644 index 000000000..07f904361 --- /dev/null +++ b/src/headless/Terminal.test.ts @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2016 The xterm.js authors. All rights reserved. + * @license MIT + */ + +import { deepStrictEqual, throws } from 'assert'; +import { Terminal } from 'headless/public/Terminal'; + +const INIT_COLS = 80; +const INIT_ROWS = 24; + +describe('Headless Terminal', () => { + let term: Terminal; + const termOptions = { + cols: INIT_COLS, + rows: INIT_ROWS + }; + + beforeEach(() => { + term = new Terminal(termOptions); + }); + + it('should throw when trying to change cols or rows', () => { + throws(() => term.setOption('cols', 1000)); + throws(() => term.setOption('rows', 1000)); + }); +}); From dab73aa26355d8897968bffe3fc3366c2ca80a28 Mon Sep 17 00:00:00 2001 From: Puneethnaik Date: Wed, 28 Jul 2021 15:56:26 +0000 Subject: [PATCH 034/164] update the viewportElement style width upon refreshing of the viewport to accomodate changes in scrollBarWidth --- demo/client.ts | 3 +++ src/browser/Viewport.ts | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/demo/client.ts b/demo/client.ts index 0bb124cd4..7b6755205 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -348,6 +348,9 @@ function initOptions(term: TerminalType): void { } else if (o === 'lineHeight' || o === 'scrollSensitivity') { term.setOption(o, parseFloat(input.value)); updateTerminalSize(); + } else if(o === 'scrollback') { + term.setOption(o, parseInt(input.value)); + setTimeout(() => updateTerminalSize(), 5); } else { term.setOption(o, parseInt(input.value)); } diff --git a/src/browser/Viewport.ts b/src/browser/Viewport.ts index 162ed174c..77325ef9c 100644 --- a/src/browser/Viewport.ts +++ b/src/browser/Viewport.ts @@ -93,7 +93,12 @@ export class Viewport extends Disposable implements IViewport { this._ignoreNextScrollEvent = true; this._viewportElement.scrollTop = scrollTop; } - + if (this._optionsService.getOption('scrollback') === 0) { + this.scrollBarWidth = 0; + } else { + this.scrollBarWidth = (this._viewportElement.offsetWidth - this._scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH; + } + this._viewportElement.style.width = (this._renderService.dimensions.actualCellWidth * (this._bufferService.cols) + this.scrollBarWidth).toString() + 'px'; this._refreshAnimationFrame = null; } /** @@ -131,6 +136,9 @@ export class Viewport extends Disposable implements IViewport { this._refresh(immediate); return; } + // This is for refreshing the viewport if scrollBarWidth has to be updated + this._refresh(immediate); + return; } /** From 12e1e422e301cad2f21006d4720883f6818f2a7f Mon Sep 17 00:00:00 2001 From: Samuel Sampson Date: Thu, 29 Jul 2021 19:35:14 +0000 Subject: [PATCH 035/164] Update RenderDebouncer to update screen readers once per second instead of once per animation frame. --- src/browser/RenderDebouncer.ts | 38 ++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/src/browser/RenderDebouncer.ts b/src/browser/RenderDebouncer.ts index 2a06fdd66..334d9a1ce 100644 --- a/src/browser/RenderDebouncer.ts +++ b/src/browser/RenderDebouncer.ts @@ -5,6 +5,8 @@ import { IDisposable } from 'common/Types'; +const RENDER_DEBOUNCE_THRESHOLD_MS = 1000; // 1 Second + /** * Debounces calls to render terminal rows using animation frames. */ @@ -14,17 +16,17 @@ export class RenderDebouncer implements IDisposable { private _rowCount: number | undefined; private _animationFrame: number | undefined; + // The last moment that the Terminal was refreshed at + private _lastRefreshMs = 0; + // Whether a trailing refresh should be triggered due to a refresh request that was throttled + private _additionalRefreshRequested = false; + constructor( private _renderCallback: (start: number, end: number) => void ) { } - public dispose(): void { - if (this._animationFrame) { - window.cancelAnimationFrame(this._animationFrame); - this._animationFrame = undefined; - } - } + public dispose(): void {} public refresh(rowStart: number | undefined, rowEnd: number | undefined, rowCount: number): void { this._rowCount = rowCount; @@ -35,11 +37,25 @@ export class RenderDebouncer implements IDisposable { this._rowStart = this._rowStart !== undefined ? Math.min(this._rowStart, rowStart) : rowStart; this._rowEnd = this._rowEnd !== undefined ? Math.max(this._rowEnd, rowEnd) : rowEnd; - if (this._animationFrame) { - return; - } + // Only refresh if the time since last refresh is above a threshold, otherwise wait for + // enough time to pass before refreshing again. + const refreshRequestTime: number = Date.now(); + if (refreshRequestTime - this._lastRefreshMs >= RENDER_DEBOUNCE_THRESHOLD_MS) { + // Enough time has lapsed since the last refresh; refresh immediately + this._lastRefreshMs = refreshRequestTime; + this._innerRefresh(); + } else if (!this._additionalRefreshRequested) { + // This is the first additional request throttled; set up trailing refresh + const elapsed = refreshRequestTime - this._lastRefreshMs; + const waitPeriodBeforeTrailingRefresh = RENDER_DEBOUNCE_THRESHOLD_MS - elapsed; + this._additionalRefreshRequested = true; - this._animationFrame = window.requestAnimationFrame(() => this._innerRefresh()); + setTimeout(() => { + this._lastRefreshMs = Date.now(); + this._innerRefresh(); + this._additionalRefreshRequested = false; + }, waitPeriodBeforeTrailingRefresh); + } } private _innerRefresh(): void { @@ -55,9 +71,9 @@ export class RenderDebouncer implements IDisposable { // Reset debouncer (this happens before render callback as the render could trigger it again) this._rowStart = undefined; this._rowEnd = undefined; - this._animationFrame = undefined; // Run render callback this._renderCallback(start, end); } } + From e82f475c9bba34bf5f1e1a6406944eaf0765c1d1 Mon Sep 17 00:00:00 2001 From: Samuel Sampson Date: Thu, 29 Jul 2021 19:57:51 +0000 Subject: [PATCH 036/164] Separate the regular render debouncer from a Time-Based debouncer to be used to update Screen Readers --- src/browser/AccessibilityManager.ts | 6 +-- src/browser/RenderDebouncer.ts | 38 +++++---------- src/browser/TimeBasedDebouncer.ts | 76 +++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 30 deletions(-) create mode 100644 src/browser/TimeBasedDebouncer.ts diff --git a/src/browser/AccessibilityManager.ts b/src/browser/AccessibilityManager.ts index c1ffc39a6..160aa3fcc 100644 --- a/src/browser/AccessibilityManager.ts +++ b/src/browser/AccessibilityManager.ts @@ -7,7 +7,7 @@ import * as Strings from 'browser/LocalizableStrings'; import { ITerminal } from 'browser/Types'; import { IBuffer } from 'common/buffer/Types'; import { isMac } from 'common/Platform'; -import { RenderDebouncer } from 'browser/RenderDebouncer'; +import { TimeBasedDebouncer } from 'browser/TimeBasedDebouncer'; import { addDisposableDomListener } from 'browser/Lifecycle'; import { Disposable } from 'common/Lifecycle'; import { ScreenDprMonitor } from 'browser/ScreenDprMonitor'; @@ -28,7 +28,7 @@ export class AccessibilityManager extends Disposable { private _liveRegion: HTMLElement; private _liveRegionLineCount: number = 0; - private _renderRowsDebouncer: RenderDebouncer; + private _renderRowsDebouncer: TimeBasedDebouncer; private _screenDprMonitor: ScreenDprMonitor; private _topBoundaryFocusListener: (e: FocusEvent) => void; @@ -72,7 +72,7 @@ export class AccessibilityManager extends Disposable { this._refreshRowsDimensions(); this._accessibilityTreeRoot.appendChild(this._rowContainer); - this._renderRowsDebouncer = new RenderDebouncer(this._renderRows.bind(this)); + this._renderRowsDebouncer = new TimeBasedDebouncer(this._renderRows.bind(this)); this._refreshRows(); this._liveRegion = document.createElement('div'); diff --git a/src/browser/RenderDebouncer.ts b/src/browser/RenderDebouncer.ts index 334d9a1ce..2a06fdd66 100644 --- a/src/browser/RenderDebouncer.ts +++ b/src/browser/RenderDebouncer.ts @@ -5,8 +5,6 @@ import { IDisposable } from 'common/Types'; -const RENDER_DEBOUNCE_THRESHOLD_MS = 1000; // 1 Second - /** * Debounces calls to render terminal rows using animation frames. */ @@ -16,17 +14,17 @@ export class RenderDebouncer implements IDisposable { private _rowCount: number | undefined; private _animationFrame: number | undefined; - // The last moment that the Terminal was refreshed at - private _lastRefreshMs = 0; - // Whether a trailing refresh should be triggered due to a refresh request that was throttled - private _additionalRefreshRequested = false; - constructor( private _renderCallback: (start: number, end: number) => void ) { } - public dispose(): void {} + public dispose(): void { + if (this._animationFrame) { + window.cancelAnimationFrame(this._animationFrame); + this._animationFrame = undefined; + } + } public refresh(rowStart: number | undefined, rowEnd: number | undefined, rowCount: number): void { this._rowCount = rowCount; @@ -37,25 +35,11 @@ export class RenderDebouncer implements IDisposable { this._rowStart = this._rowStart !== undefined ? Math.min(this._rowStart, rowStart) : rowStart; this._rowEnd = this._rowEnd !== undefined ? Math.max(this._rowEnd, rowEnd) : rowEnd; - // Only refresh if the time since last refresh is above a threshold, otherwise wait for - // enough time to pass before refreshing again. - const refreshRequestTime: number = Date.now(); - if (refreshRequestTime - this._lastRefreshMs >= RENDER_DEBOUNCE_THRESHOLD_MS) { - // Enough time has lapsed since the last refresh; refresh immediately - this._lastRefreshMs = refreshRequestTime; - this._innerRefresh(); - } else if (!this._additionalRefreshRequested) { - // This is the first additional request throttled; set up trailing refresh - const elapsed = refreshRequestTime - this._lastRefreshMs; - const waitPeriodBeforeTrailingRefresh = RENDER_DEBOUNCE_THRESHOLD_MS - elapsed; - this._additionalRefreshRequested = true; - - setTimeout(() => { - this._lastRefreshMs = Date.now(); - this._innerRefresh(); - this._additionalRefreshRequested = false; - }, waitPeriodBeforeTrailingRefresh); + if (this._animationFrame) { + return; } + + this._animationFrame = window.requestAnimationFrame(() => this._innerRefresh()); } private _innerRefresh(): void { @@ -71,9 +55,9 @@ export class RenderDebouncer implements IDisposable { // Reset debouncer (this happens before render callback as the render could trigger it again) this._rowStart = undefined; this._rowEnd = undefined; + this._animationFrame = undefined; // Run render callback this._renderCallback(start, end); } } - diff --git a/src/browser/TimeBasedDebouncer.ts b/src/browser/TimeBasedDebouncer.ts new file mode 100644 index 000000000..8f444c4fe --- /dev/null +++ b/src/browser/TimeBasedDebouncer.ts @@ -0,0 +1,76 @@ +/** + * Copyright (c) 2018 The xterm.js authors. All rights reserved. + * @license MIT + */ + +const RENDER_DEBOUNCE_THRESHOLD_MS = 1000; // 1 Second + +/** + * Debounces calls to update screen readers to update at most once per second. + */ +export class TimeBasedDebouncer { + private _rowStart: number | undefined; + private _rowEnd: number | undefined; + private _rowCount: number | undefined; + + // The last moment that the Terminal was refreshed at + private _lastRefreshMs = 0; + // Whether a trailing refresh should be triggered due to a refresh request that was throttled + private _additionalRefreshRequested = false; + + constructor( + private _renderCallback: (start: number, end: number) => void + ) { + } + + public dispose(): void {} + + public refresh(rowStart: number | undefined, rowEnd: number | undefined, rowCount: number): void { + this._rowCount = rowCount; + // Get the min/max row start/end for the arg values + rowStart = rowStart !== undefined ? rowStart : 0; + rowEnd = rowEnd !== undefined ? rowEnd : this._rowCount - 1; + // Set the properties to the updated values + this._rowStart = this._rowStart !== undefined ? Math.min(this._rowStart, rowStart) : rowStart; + this._rowEnd = this._rowEnd !== undefined ? Math.max(this._rowEnd, rowEnd) : rowEnd; + + // Only refresh if the time since last refresh is above a threshold, otherwise wait for + // enough time to pass before refreshing again. + const refreshRequestTime: number = Date.now(); + if (refreshRequestTime - this._lastRefreshMs >= RENDER_DEBOUNCE_THRESHOLD_MS) { + // Enough time has lapsed since the last refresh; refresh immediately + this._lastRefreshMs = refreshRequestTime; + this._innerRefresh(); + } else if (!this._additionalRefreshRequested) { + // This is the first additional request throttled; set up trailing refresh + const elapsed = refreshRequestTime - this._lastRefreshMs; + const waitPeriodBeforeTrailingRefresh = RENDER_DEBOUNCE_THRESHOLD_MS - elapsed; + this._additionalRefreshRequested = true; + + setTimeout(() => { + this._lastRefreshMs = Date.now(); + this._innerRefresh(); + this._additionalRefreshRequested = false; + }, waitPeriodBeforeTrailingRefresh); + } + } + + private _innerRefresh(): void { + // Make sure values are set + if (this._rowStart === undefined || this._rowEnd === undefined || this._rowCount === undefined) { + return; + } + + // Clamp values + const start = Math.max(this._rowStart, 0); + const end = Math.min(this._rowEnd, this._rowCount - 1); + + // Reset debouncer (this happens before render callback as the render could trigger it again) + this._rowStart = undefined; + this._rowEnd = undefined; + + // Run render callback + this._renderCallback(start, end); + } +} + From 4a9ecb33bd73ffcab015eaf6768443ff9224d02e Mon Sep 17 00:00:00 2001 From: Samuel Sampson Date: Thu, 29 Jul 2021 19:58:59 +0000 Subject: [PATCH 037/164] Remove unneeded dispose method from TimeBasedDebouncer --- src/browser/TimeBasedDebouncer.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/browser/TimeBasedDebouncer.ts b/src/browser/TimeBasedDebouncer.ts index 8f444c4fe..64226085a 100644 --- a/src/browser/TimeBasedDebouncer.ts +++ b/src/browser/TimeBasedDebouncer.ts @@ -23,8 +23,6 @@ export class TimeBasedDebouncer { ) { } - public dispose(): void {} - public refresh(rowStart: number | undefined, rowEnd: number | undefined, rowCount: number): void { this._rowCount = rowCount; // Get the min/max row start/end for the arg values From 732927b0e225e598bcfaa8ea67b685c2776b1c43 Mon Sep 17 00:00:00 2001 From: Samuel Sampson Date: Thu, 29 Jul 2021 20:20:02 +0000 Subject: [PATCH 038/164] Add back IDisposable implementation in TimeBasedDebouncer for the ease of interoperability with RenderDebouncer --- src/browser/TimeBasedDebouncer.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/browser/TimeBasedDebouncer.ts b/src/browser/TimeBasedDebouncer.ts index 64226085a..843787d5f 100644 --- a/src/browser/TimeBasedDebouncer.ts +++ b/src/browser/TimeBasedDebouncer.ts @@ -5,10 +5,12 @@ const RENDER_DEBOUNCE_THRESHOLD_MS = 1000; // 1 Second +import { IDisposable } from 'common/Types'; + /** * Debounces calls to update screen readers to update at most once per second. */ -export class TimeBasedDebouncer { +export class TimeBasedDebouncer implements IDisposable { private _rowStart: number | undefined; private _rowEnd: number | undefined; private _rowCount: number | undefined; @@ -23,6 +25,8 @@ export class TimeBasedDebouncer { ) { } + public dispose(): void {} + public refresh(rowStart: number | undefined, rowEnd: number | undefined, rowCount: number): void { this._rowCount = rowCount; // Get the min/max row start/end for the arg values From 8c94980315076e9c833b27fc3f8aff2bd7c32f67 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sat, 31 Jul 2021 18:53:23 +0200 Subject: [PATCH 039/164] Properly dispose of CursorBlinkStateManager --- src/browser/renderer/CursorRenderLayer.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/browser/renderer/CursorRenderLayer.ts b/src/browser/renderer/CursorRenderLayer.ts index 8fda0b356..65109a80c 100644 --- a/src/browser/renderer/CursorRenderLayer.ts +++ b/src/browser/renderer/CursorRenderLayer.ts @@ -58,6 +58,14 @@ export class CursorRenderLayer extends BaseRenderLayer { // TODO: Consider initial options? Maybe onOptionsChanged should be called at the end of open? } + public dispose(): void { + if (this._cursorBlinkStateManager) { + this._cursorBlinkStateManager.dispose(); + this._cursorBlinkStateManager = undefined; + } + super.dispose(); + } + public resize(dim: IRenderDimensions): void { super.resize(dim); // Resizing the canvas discards the contents of the canvas so clear state From 4c4160ae0324ba1f658b051062299a33b3195cfd Mon Sep 17 00:00:00 2001 From: Erik Welander Date: Wed, 4 Aug 2021 11:31:32 -0700 Subject: [PATCH 040/164] Add missing escape Previously the \ was unnecessarily escaping the ';'. --- addons/xterm-addon-search/src/SearchAddon.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/xterm-addon-search/src/SearchAddon.ts b/addons/xterm-addon-search/src/SearchAddon.ts index 4a73d9980..1409328d3 100644 --- a/addons/xterm-addon-search/src/SearchAddon.ts +++ b/addons/xterm-addon-search/src/SearchAddon.ts @@ -23,7 +23,7 @@ export interface ISearchResult { row: number; } -const NON_WORD_CHARACTERS = ' ~!@#$%^&*()+`-=[]{}|\;:"\',./<>?'; +const NON_WORD_CHARACTERS = ' ~!@#$%^&*()+`-=[]{}|\\;:"\',./<>?'; const LINES_CACHE_TIME_TO_LIVE = 15 * 1000; // 15 secs export class SearchAddon implements ITerminalAddon { From e01e9c9584fb9d1fb4eedb6c282439edfad38893 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Mon, 9 Aug 2021 14:23:09 -0700 Subject: [PATCH 041/164] start on #130406 --- src/browser/renderer/BaseRenderLayer.ts | 109 +++++++++++- src/browser/renderer/BoxCharacters.ts | 213 ++++++++++++++++++++++++ 2 files changed, 313 insertions(+), 9 deletions(-) create mode 100644 src/browser/renderer/BoxCharacters.ts diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 7986e5102..ce2d8058c 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -17,6 +17,7 @@ import { IBufferService, IOptionsService } from 'common/services/Services'; import { throwIfFalsy } from 'browser/renderer/RendererUtils'; import { channels, color, rgba } from 'browser/Color'; import { removeElementFromParent } from 'browser/Dom'; +import { boxDrawingBoxes, boxDrawingLineSegments } from 'browser/renderer/BoxCharacters'; export abstract class BaseRenderLayer implements IRenderLayer { private _canvas: HTMLCanvasElement; @@ -259,10 +260,13 @@ export abstract class BaseRenderLayer implements IRenderLayer { this._ctx.font = this._getFont(false, false); this._ctx.textBaseline = 'ideographic'; this._clipRow(y); - this._ctx.fillText( - cell.getChars(), - x * this._scaledCellWidth + this._scaledCharLeft, - y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight); + // TODO: fix + if (!this._drawBoxChar(cell, x, y)) { + this._ctx.fillText( + cell.getChars(), + x * this._scaledCellWidth + this._scaledCharLeft, + y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight); + } } /** @@ -373,14 +377,101 @@ export abstract class BaseRenderLayer implements IRenderLayer { if (cell.isDim()) { this._ctx.globalAlpha = DIM_OPACITY; } - // Draw the character - this._ctx.fillText( - cell.getChars(), - x * this._scaledCellWidth + this._scaledCharLeft, - y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight); + if (!this._drawBoxChar(cell, x, y)) { + // Draw the character + this._ctx.fillText( + cell.getChars(), + x * this._scaledCellWidth + this._scaledCharLeft, + y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight); + } this._ctx.restore(); } + private _drawBoxChar(cell: ICellData, x: number, y: number): boolean { + const char = cell.getChars(); + + const boxes = boxDrawingBoxes[char]; + if (boxes) { + this._ctx.strokeStyle = this._ctx.fillStyle; + const xOffset = x * this._scaledCellWidth + this._scaledCharLeft; + const yOffset = y * this._scaledCellHeight + this._scaledCharTop; + const xEighth = this._scaledCellWidth / 8; + const yEighth = this._scaledCellHeight / 8; + + for (let i = 0; i < boxes.length; i++) { + const box = boxes[i]; + this._ctx.fillRect( + xOffset + (box.x * xEighth), + yOffset + (box.y * yEighth), + (box.w * xEighth), + (box.h * yEighth)); + } + + return true; + } + + const ops = boxDrawingLineSegments[char]; + if (!ops) { + return false; + } + + // TODO: Clean below + const scale = window.devicePixelRatio; + this._ctx.strokeStyle = this._ctx.fillStyle; + this._ctx.lineWidth = scale; + + const xOffset = x * this._scaledCellWidth + this._scaledCharLeft; + const yOffset = y * this._scaledCellHeight + this._scaledCharTop; + const horizontalCenter = this._scaledCellWidth / 2; + const verticalCenter = this._scaledCellHeight / 2; + const xPoints = [ + xOffset, + xOffset + horizontalCenter - scale, + xOffset + horizontalCenter - scale / 2, + xOffset + horizontalCenter, + xOffset + horizontalCenter + scale / 2, + xOffset + horizontalCenter + scale, + xOffset + this._scaledCellWidth + ]; + const yPoints = [ + yOffset, + yOffset + verticalCenter - scale, + yOffset + verticalCenter - scale / 2, + yOffset + verticalCenter, + yOffset + verticalCenter + scale / 2, + yOffset + verticalCenter + scale, + yOffset + this._scaledCellHeight + ]; + + for (let i = 0; i < ops.length; i++) { + const op = ops[i]; + + if (i === 0 || (op.x1 !== ops[i - 1].x2 || op.y1 !== ops[i - 1].y2)) { + this._ctx.beginPath(); + this._ctx.moveTo(xPoints[op.x1], yPoints[op.y1]); + } + + if (typeof op.cx1 !== 'undefined') { + // Draw curve + this._ctx.bezierCurveTo( + xPoints[op.cx1], + yPoints[op.cy1], + xPoints[op.cx2], + yPoints[op.cy2], + xPoints[op.x2], + yPoints[op.y2]); + } else { + // Draw line + this._ctx.lineTo(xPoints[op.x2], yPoints[op.y2]); + } + + this._ctx.stroke(); + } + + return true; + } + + /** * Clips a row to ensure no pixels will be drawn outside the cells in the row. * @param y The row to clip. diff --git a/src/browser/renderer/BoxCharacters.ts b/src/browser/renderer/BoxCharacters.ts new file mode 100644 index 000000000..221a0e4f9 --- /dev/null +++ b/src/browser/renderer/BoxCharacters.ts @@ -0,0 +1,213 @@ +export const boxDrawingLineSegments: { [index: string]: any } = { + '─': [{ x1: 0, y1: 3, x2: 6, y2: 3 }], + '━': [{ x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 6, y2: 4 }], + '│': [{ x1: 3, y1: 0, x2: 3, y2: 6 }], + '┃': [{ x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }], + '┌': [{ x1: 6, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], + '┍': [{ x1: 6, y1: 2, x2: 3, y2: 2 }, { x1: 3, y1: 2, x2: 3, y2: 6 }, { x1: 6, y1: 4, x2: 3, y2: 4 }], + '┎': [{ x1: 6, y1: 3, x2: 2, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], + '┏': [{ x1: 6, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 6 }, { x1: 6, y1: 4, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 4, y2: 6 }], + '┐': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], + '┑': [{ x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 3, y1: 2, x2: 3, y2: 6 }, { x1: 0, y1: 4, x2: 3, y2: 4 }], + '┒': [{ x1: 0, y1: 3, x2: 4, y2: 3 }, { x1: 4, y1: 3, x2: 4, y2: 6 }, { x1: 2, y1: 3, x2: 2, y2: 6 }], + '┓': [{ x1: 0, y1: 2, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 4, y2: 6 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }], + '└': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], + '┕': [{ x1: 3, y1: 0, x2: 3, y2: 4 }, { x1: 3, y1: 4, x2: 6, y2: 4 }, { x1: 3, y1: 2, x2: 6, y2: 2 }], + '┖': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 2, y1: 3, x2: 6, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }], + '┗': [{ x1: 2, y1: 0, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 6, y2: 4 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }], + '┘': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 0 }], + '┙': [{ x1: 0, y1: 4, x2: 3, y2: 4 }, { x1: 3, y1: 4, x2: 3, y2: 0 }, { x1: 0, y1: 2, x2: 3, y2: 2 }], + '┚': [{ x1: 0, y1: 3, x2: 4, y2: 3 }, { x1: 4, y1: 3, x2: 4, y2: 0 }, { x1: 2, y1: 3, x2: 2, y2: 0 }], + '┛': [{ x1: 0, y1: 4, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 4, y2: 0 }, { x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }], + '├': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], + '┝': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], + '┞': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }, { x1: 4, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], + '┟': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], + '┠': [{ x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }, { x1: 4, y1: 3, x2: 6, y2: 3 }], + '┡': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 2, y1: 3, x2: 6, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], + '┢': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 2, y1: 6, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 6, y2: 2 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], + '┣': [{ x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }, { x1: 6, y1: 4, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 4, y2: 6 }], + '┤': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 0, y1: 3, x2: 3, y2: 3 }], + '┥': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }], + '┦': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }, { x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], + '┧': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 0, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], + '┨': [{ x1: 0, y1: 3, x2: 2, y2: 3 }, { x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }], + '┩': [{ x1: 2, y1: 0, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 0, y2: 2 }, { x1: 4, y1: 0, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 0, y2: 4 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], + '┪': [{ x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 3, y1: 2, x2: 3, y2: 6 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 3, y1: 0, x2: 3, y2: 3 }], + '┫': [{ x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }], + '┬': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], + '┭': [{ x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }, { x1: 3, y1: 6, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], + '┮': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }, { x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], + '┯': [{ x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 6, y2: 4 }, { x1: 3, y1: 4, x2: 3, y2: 6 }], + '┰': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], + '┱': [{ x1: 0, y1: 2, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 4, y2: 6 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], + '┲': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 2, y1: 6, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 6, y2: 2 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], + '┳': [{ x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], + '┴': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 0, x2: 3, y2: 3 }], + '┵': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }, { x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }], + '┶': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 0 }, { x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], + '┷': [{ x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 6, y2: 4 }, { x1: 3, y1: 0, x2: 3, y2: 3 }], + '┸': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }], + '┹': [{ x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 0, y1: 4, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 4, y2: 0 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], + '┺': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 2, y1: 0, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 6, y2: 4 }, { x1: 3, y1: 0, x2: 3, y2: 2 }, { x1: 3, y1: 2, x2: 6, y2: 2 }], + '┻': [{ x1: 0, y1: 4, x2: 6, y2: 4 }, { x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }], + '┼': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 0, x2: 3, y2: 6 }], + '┽': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 3, y1: 3, x2: 6, y2: 3 }, { x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }], + '┾': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], + '┿': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 6, y2: 4 }], + '╀': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }, { x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }], + '╁': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], + '╂': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }], + '╃': [{ x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 0, y1: 4, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 4, y2: 0 }, { x1: 3, y1: 6, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], + '╄': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }, { x1: 2, y1: 0, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 6, y2: 4 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }], + '╅': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }, { x1: 0, y1: 2, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 4, y2: 6 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }], + '╆': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 0 }, { x1: 2, y1: 6, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 6, y2: 2 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], + '╇': [{ x1: 0, y1: 4, x2: 6, y2: 4 }, { x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], + '╈': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], + '╉': [{ x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], + '╊': [{ x1: 0, y1: 3, x2: 2, y2: 3 }, { x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], + '╋': [{ x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 6, y2: 4 }, { x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }], + '╌': [{ x1: 0, y1: 3, x2: 2, y2: 3 }, { x1: 4, y1: 3, x2: 6, y2: 3 }], + '╍': [{ x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 4, y1: 2, x2: 6, y2: 2 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], + '╎': [{ x1: 3, y1: 0, x2: 3, y2: 2 }, { x1: 3, y1: 4, x2: 3, y2: 6 }], + '╏': [{ x1: 2, y1: 0, x2: 2, y2: 2 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], + '═': [{ x1: 0, y1: 1, x2: 6, y2: 1 }, { x1: 0, y1: 5, x2: 6, y2: 5 }], + '║': [{ x1: 1, y1: 0, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 6 }], + '╒': [{ x1: 6, y1: 1, x2: 3, y2: 1 }, { x1: 3, y1: 1, x2: 3, y2: 6 }, { x1: 6, y1: 5, x2: 3, y2: 5 }], + '╓': [{ x1: 6, y1: 3, x2: 1, y2: 3 }, { x1: 1, y1: 3, x2: 1, y2: 6 }, { x1: 5, y1: 3, x2: 5, y2: 6 }], + '╔': [{ x1: 6, y1: 1, x2: 1, y2: 1 }, { x1: 1, y1: 1, x2: 1, y2: 6 }, { x1: 6, y1: 5, x2: 5, y2: 5 }, { x1: 5, y1: 5, x2: 5, y2: 6 }], + '╕': [{ x1: 0, y1: 1, x2: 3, y2: 1 }, { x1: 3, y1: 1, x2: 3, y2: 6 }, { x1: 0, y1: 5, x2: 3, y2: 5 }], + '╖': [{ x1: 0, y1: 3, x2: 5, y2: 3 }, { x1: 5, y1: 3, x2: 5, y2: 6 }, { x1: 1, y1: 3, x2: 1, y2: 6 }], + '╗': [{ x1: 0, y1: 1, x2: 5, y2: 1 }, { x1: 5, y1: 1, x2: 5, y2: 6 }, { x1: 0, y1: 5, x2: 1, y2: 5 }, { x1: 1, y1: 5, x2: 1, y2: 6 }], + '╘': [{ x1: 3, y1: 0, x2: 3, y2: 5 }, { x1: 3, y1: 5, x2: 6, y2: 5 }, { x1: 3, y1: 1, x2: 6, y2: 1 }], + '╙': [{ x1: 1, y1: 0, x2: 1, y2: 3 }, { x1: 1, y1: 3, x2: 6, y2: 3 }, { x1: 5, y1: 0, x2: 5, y2: 3 }], + '╚': [{ x1: 1, y1: 0, x2: 1, y2: 5 }, { x1: 1, y1: 5, x2: 6, y2: 5 }, { x1: 5, y1: 0, x2: 5, y2: 1 }, { x1: 5, y1: 1, x2: 6, y2: 1 }], + '╛': [{ x1: 0, y1: 1, x2: 3, y2: 1 }, { x1: 0, y1: 5, x2: 3, y2: 5 }, { x1: 3, y1: 5, x2: 3, y2: 0 }], + '╜': [{ x1: 0, y1: 3, x2: 5, y2: 3 }, { x1: 5, y1: 3, x2: 5, y2: 0 }, { x1: 1, y1: 3, x2: 1, y2: 0 }], + '╝': [{ x1: 0, y1: 1, x2: 1, y2: 1 }, { x1: 1, y1: 1, x2: 1, y2: 0 }, { x1: 0, y1: 5, x2: 5, y2: 5 }, { x1: 5, y1: 5, x2: 5, y2: 0 }], + '╞': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 3, y1: 1, x2: 6, y2: 1 }, { x1: 3, y1: 5, x2: 6, y2: 5 }], + '╟': [{ x1: 1, y1: 0, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 6 }, { x1: 5, y1: 3, x2: 6, y2: 3 }], + '╠': [{ x1: 1, y1: 0, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 1 }, { x1: 5, y1: 1, x2: 6, y2: 1 }, { x1: 5, y1: 6, x2: 5, y2: 5 }, { x1: 5, y1: 5, x2: 6, y2: 5 }], + '╡': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 0, y1: 1, x2: 3, y2: 1 }, { x1: 0, y1: 5, x2: 3, y2: 5 }], + '╢': [{ x1: 0, y1: 3, x2: 1, y2: 3 }, { x1: 1, y1: 0, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 6 }], + '╣': [{ x1: 0, y1: 1, x2: 1, y2: 1 }, { x1: 1, y1: 1, x2: 1, y2: 0 }, { x1: 0, y1: 5, x2: 1, y2: 5 }, { x1: 1, y1: 5, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 6 }], + '╤': [{ x1: 0, y1: 1, x2: 6, y2: 1 }, { x1: 0, y1: 5, x2: 6, y2: 5 }, { x1: 3, y1: 5, x2: 3, y2: 6 }], + '╥': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 1, y1: 3, x2: 1, y2: 6 }, { x1: 5, y1: 3, x2: 5, y2: 6 }], + '╦': [{ x1: 0, y1: 1, x2: 6, y2: 1 }, { x1: 0, y1: 5, x2: 1, y2: 5 }, { x1: 1, y1: 5, x2: 1, y2: 6 }, { x1: 5, y1: 6, x2: 5, y2: 5 }, { x1: 5, y1: 5, x2: 6, y2: 5 }], + '╧': [{ x1: 0, y1: 5, x2: 6, y2: 5 }, { x1: 0, y1: 1, x2: 6, y2: 1 }, { x1: 3, y1: 0, x2: 3, y2: 1 }], + '╨': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 1, y1: 0, x2: 1, y2: 3 }, { x1: 5, y1: 0, x2: 5, y2: 3 }], + '╩': [{ x1: 0, y1: 1, x2: 1, y2: 1 }, { x1: 1, y1: 1, x2: 1, y2: 0 }, { x1: 5, y1: 0, x2: 5, y2: 1 }, { x1: 5, y1: 1, x2: 6, y2: 1 }, { x1: 0, y1: 5, x2: 6, y2: 5 }], + '╪': [{ x1: 0, y1: 1, x2: 6, y2: 1 }, { x1: 0, y1: 5, x2: 6, y2: 5 }, { x1: 3, y1: 0, x2: 3, y2: 6 }], + '╫': [{ x1: 1, y1: 0, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 6 }, { x1: 0, y1: 3, x2: 6, y2: 3 }], + '╬': [{ x1: 0, y1: 1, x2: 1, y2: 1 }, { x1: 1, y1: 1, x2: 1, y2: 0 }, { x1: 5, y1: 0, x2: 5, y2: 1 }, { x1: 5, y1: 1, x2: 6, y2: 1 }, { x1: 6, y1: 5, x2: 5, y2: 5 }, { x1: 5, y1: 5, x2: 5, y2: 6 }, { x1: 1, y1: 6, x2: 1, y2: 5 }, { x1: 1, y1: 5, x2: 0, y2: 5 }], + '╭': [{ x1: 6, y1: 3, x2: 3, y2: 6, cx1: 3, cy1: 3, cx2: 3, cy2: 3 }], + '╮': [{ x1: 0, y1: 3, x2: 3, y2: 6, cx1: 3, cy1: 3, cx2: 3, cy2: 3 }], + '╯': [{ x1: 0, y1: 3, x2: 3, y2: 0, cx1: 3, cy1: 3, cx2: 3, cy2: 3 }], + '╰': [{ x1: 3, y1: 0, x2: 6, y2: 3, cx1: 3, cy1: 3, cx2: 3, cy2: 3 }], + '╱': [{ x1: 0, y1: 6, x2: 6, y2: 0 }], + '╲': [{ x1: 0, y1: 0, x2: 6, y2: 6 }], + '╳': [{ x1: 0, y1: 6, x2: 6, y2: 0 }, { x1: 0, y1: 0, x2: 6, y2: 6 }], + '╴': [{ x1: 0, y1: 3, x2: 3, y2: 3 }], + '╵': [{ x1: 3, y1: 0, x2: 3, y2: 3 }], + '╶': [{ x1: 3, y1: 3, x2: 6, y2: 3 }], + '╷': [{ x1: 3, y1: 3, x2: 3, y2: 6 }], + '╸': [{ x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }], + '╹': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }], + '╺': [{ x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], + '╻': [{ x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], + '╼': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], + '╽': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], + '╾': [{ x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], + '╿': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }] +}; + +export const boxDrawingBoxes: { [index: string]: any } = { + '▀': [{ x: 0, y: 0, w: 8, h: 4 }], + '█': [{ x: 0, y: 0, w: 8, h: 8 }], + '▇': [{ x: 0, y: 1, w: 8, h: 7 }], + '▆': [{ x: 0, y: 2, w: 8, h: 6 }], + '▅': [{ x: 0, y: 3, w: 8, h: 5 }], + '▄': [{ x: 0, y: 4, w: 8, h: 4 }], + '▃': [{ x: 0, y: 5, w: 8, h: 3 }], + '▂': [{ x: 0, y: 6, w: 8, h: 2 }], + '▁': [{ x: 0, y: 7, w: 8, h: 1 }], + '▉': [{ x: 0, y: 0, w: 7, h: 8 }], + '▊': [{ x: 0, y: 0, w: 6, h: 8 }], + '▋': [{ x: 0, y: 0, w: 5, h: 8 }], + '▌': [{ x: 0, y: 0, w: 4, h: 8 }], + '▍': [{ x: 0, y: 0, w: 3, h: 8 }], + '▎': [{ x: 0, y: 0, w: 2, h: 8 }], + '▏': [{ x: 0, y: 0, w: 1, h: 8 }], + + // VERTICAL ONE EIGHTH BLOCK-2 through VERTICAL ONE EIGHTH BLOCK-7 + '\u{1FB70}': [{ x: 1, y: 0, w: 1, h: 8 }], + '\u{1FB71}': [{ x: 2, y: 0, w: 1, h: 8 }], + '\u{1FB72}': [{ x: 3, y: 0, w: 1, h: 8 }], + '\u{1FB73}': [{ x: 4, y: 0, w: 1, h: 8 }], + '\u{1FB74}': [{ x: 5, y: 0, w: 1, h: 8 }], + '\u{1FB75}': [{ x: 6, y: 0, w: 1, h: 8 }], + // RIGHT ONE EIGHTH BLOCK + '▕': [{ x: 7, y: 0, w: 1, h: 8 }], + + // UPPER ONE EIGHTH BLOCK + '▔': [{ x: 0, y: 0, w: 8, h: 1 }], + // HORIZONTAL ONE EIGHTH BLOCK-2 through HORIZONTAL ONE EIGHTH BLOCK-7 + '\u{1FB76}': [{ x: 0, y: 1, w: 8, h: 1 }], + '\u{1FB77}': [{ x: 0, y: 2, w: 8, h: 1 }], + '\u{1FB78}': [{ x: 0, y: 3, w: 8, h: 1 }], + '\u{1FB79}': [{ x: 0, y: 4, w: 8, h: 1 }], + '\u{1FB7A}': [{ x: 0, y: 5, w: 8, h: 1 }], + '\u{1FB7B}': [{ x: 0, y: 6, w: 8, h: 1 }], + + // LEFT AND LOWER ONE EIGHTH BLOCK + '\u{1FB7C}': [{ x: 0, y: 0, w: 1, h: 8 }, { x: 0, y: 7, w: 8, h: 1 }], + // LEFT AND UPPER ONE EIGHTH BLOCK + '\u{1FB7D}': [{ x: 0, y: 0, w: 1, h: 8 }, { x: 0, y: 0, w: 8, h: 1 }], + // RIGHT AND UPPER ONE EIGHTH BLOCK + '\u{1FB7E}': [{ x: 7, y: 0, w: 1, h: 8 }, { x: 0, y: 0, w: 8, h: 1 }], + // RIGHT AND LOWER ONE EIGHTH BLOCK + '\u{1FB7F}': [{ x: 7, y: 0, w: 1, h: 8 }, { x: 0, y: 7, w: 8, h: 1 }], + // UPPER AND LOWER ONE EIGHTH BLOCK + '\u{1FB80}': [{ x: 0, y: 0, w: 8, h: 1 }, { x: 0, y: 7, w: 8, h: 1 }], + // HORIZONTAL ONE EIGHTH BLOCK-1358 + '\u{1FB81}': [{ x: 0, y: 0, w: 8, h: 1 }, { x: 0, y: 2, w: 8, h: 1 }, { x: 0, y: 4, w: 8, h: 1 }, { x: 0, y: 7, w: 8, h: 1 }], + + // UPPER ONE QUARTER BLOCK + '\u{1FB82}': [{ x: 0, y: 0, w: 8, h: 2 }], + // UPPER THREE EIGHTHS BLOCK + '\u{1FB83}': [{ x: 0, y: 0, w: 8, h: 3 }], + // UPPER FIVE EIGHTHS BLOCK + '\u{1FB84}': [{ x: 0, y: 0, w: 8, h: 5 }], + // UPPER THREE QUARTERS BLOCK + '\u{1FB85}': [{ x: 0, y: 0, w: 8, h: 6 }], + // UPPER SEVEN EIGHTHS BLOCK + '\u{1FB86}': [{ x: 0, y: 0, w: 8, h: 7 }], + + // RIGHT ONE QUARTER BLOCK + '\u{1FB87}': [{ x: 6, y: 0, w: 2, h: 8 }], + // RIGHT THREE EIGHTHS B0OCK + '\u{1FB88}': [{ x: 5, y: 0, w: 3, h: 8 }], + // RIGHT FIVE EIGHTHS BL0CK + '\u{1FB89}': [{ x: 3, y: 0, w: 5, h: 8 }], + // RIGHT THREE QUARTERS 0LOCK + '\u{1FB8A}': [{ x: 2, y: 0, w: 6, h: 8 }], + // RIGHT SEVEN EIGHTHS B0OCK + '\u{1FB8B}': [{ x: 1, y: 0, w: 7, h: 8 }], + + // CHECKER BOARD FILL + '\u{1FB95}': [ + { x: 0, y: 0, w: 2, h: 2 }, { x: 4, y: 0, w: 2, h: 2 }, + { x: 2, y: 2, w: 2, h: 2 }, { x: 6, y: 2, w: 2, h: 2 }, + { x: 0, y: 4, w: 2, h: 2 }, { x: 4, y: 4, w: 2, h: 2 }, + { x: 2, y: 6, w: 2, h: 2 }, { x: 6, y: 6, w: 2, h: 2 } + ], + // INVERSE CHECKER BOARD FILL + '\u{1FB96}': [ + { x: 2, y: 0, w: 2, h: 2 }, { x: 6, y: 0, w: 2, h: 2 }, + { x: 0, y: 2, w: 2, h: 2 }, { x: 4, y: 2, w: 2, h: 2 }, + { x: 2, y: 4, w: 2, h: 2 }, { x: 6, y: 4, w: 2, h: 2 }, + { x: 0, y: 6, w: 2, h: 2 }, { x: 4, y: 6, w: 2, h: 2 } + ], + // HEAVY HORIZONTAL FILL (upper middle and lower one quarter block) + '\u{1FB97}': [{ x: 0, y: 2, w: 8, h: 2 }, { x: 0, y: 6, w: 8, h: 2 }] +}; From 3b3ef09d87ca6df46bfddb2d44c7d37def094a38 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Mon, 9 Aug 2021 14:52:47 -0700 Subject: [PATCH 042/164] keep working --- src/browser/renderer/BaseRenderLayer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index ce2d8058c..188816ec9 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -401,8 +401,8 @@ export abstract class BaseRenderLayer implements IRenderLayer { for (let i = 0; i < boxes.length; i++) { const box = boxes[i]; this._ctx.fillRect( - xOffset + (box.x * xEighth), - yOffset + (box.y * yEighth), + xOffset + (box.x*xEighth), + yOffset + (box.y*yEighth), (box.w * xEighth), (box.h * yEighth)); } From a48cffd4ab60f9e17c594cbb86f3d9f6fb0718bb Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Mon, 9 Aug 2021 18:53:04 -0700 Subject: [PATCH 043/164] Add HashiCorp Nomad to the real world uses list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The equivalent of https://github.com/xtermjs/xtermjs.org/pull/149 but in the right place this time 🙂 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0ac211ed3..9d926afeb 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,7 @@ Xterm.js is used in several world-class applications to provide great terminal e - [**Wizard Assistant**](https://wizardassistant.com/): Wizard Assistant comes with advanced automation tools, preloaded common and special time-saving commands, and a built-in SSH terminal. Now you can remotely administer, troubleshoot, and analyze any system with ease. - [**ucli**](https://github.com/tsadarsh/ucli): Command Line for everyone :family_man_woman_girl_boy: at [www.ucli.tech](https://www.ucli.tech). - [**Tess**](https://github.com/SquitchYT/Tess/): Simple Terminal Fully Customizable for Everyone. +- [**HashiCorp Nomad**](https://www.nomadproject.io/): A container orchestrator with the ability to connect to remote tasks via a web interface using websockets and xterm.js. - [And much more...](https://github.com/xtermjs/xterm.js/network/dependents) Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it on our list. Note: Please add any new contributions to the end of the list only. From f43fcafc9925bc917f0fa23eb0b27abc828a10e4 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 10 Aug 2021 05:08:03 -0700 Subject: [PATCH 044/164] Move addon manager to common and use in xterm-core --- src/browser/public/Terminal.ts | 6 +- .../public/AddonManager.test.ts | 0 .../public/AddonManager.ts | 0 src/headless/public/Terminal.ts | 10 +- typings/xterm-core.d.ts | 227 +++++++++--------- 5 files changed, 128 insertions(+), 115 deletions(-) rename src/{browser => common}/public/AddonManager.test.ts (100%) rename src/{browser => common}/public/AddonManager.ts (100%) diff --git a/src/browser/public/Terminal.ts b/src/browser/public/Terminal.ts index adfee5448..8b7b5d2ee 100644 --- a/src/browser/public/Terminal.ts +++ b/src/browser/public/Terminal.ts @@ -5,12 +5,12 @@ import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBufferNamespace as IBufferNamespaceApi, IParser, ILinkProvider, IUnicodeHandling, FontWeight } from 'xterm'; import { ITerminal } from 'browser/Types'; -import { Terminal as TerminalCore } from '../Terminal'; -import * as Strings from '../LocalizableStrings'; +import { Terminal as TerminalCore } from 'browser/Terminal'; +import * as Strings from 'browser/LocalizableStrings'; import { IEvent } from 'common/EventEmitter'; import { ParserApi } from 'common/public/ParserApi'; import { UnicodeApi } from 'common/public/UnicodeApi'; -import { AddonManager } from './AddonManager'; +import { AddonManager } from 'common/public/AddonManager'; import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi'; export class Terminal implements ITerminalApi { diff --git a/src/browser/public/AddonManager.test.ts b/src/common/public/AddonManager.test.ts similarity index 100% rename from src/browser/public/AddonManager.test.ts rename to src/common/public/AddonManager.test.ts diff --git a/src/browser/public/AddonManager.ts b/src/common/public/AddonManager.ts similarity index 100% rename from src/browser/public/AddonManager.ts rename to src/common/public/AddonManager.ts diff --git a/src/headless/public/Terminal.ts b/src/headless/public/Terminal.ts index 4b27a04b9..44f9753a2 100644 --- a/src/headless/public/Terminal.ts +++ b/src/headless/public/Terminal.ts @@ -7,16 +7,19 @@ 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, IParser, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-core'; +import { IBufferNamespace as IBufferNamespaceApi, IMarker, IParser, ITerminalAddon, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-core'; import { Terminal as TerminalCore } from 'headless/Terminal'; +import { AddonManager } from 'common/public/AddonManager'; export class Terminal implements ITerminalApi { private _core: TerminalCore; + private _addonManager: AddonManager; private _parser: IParser | undefined; private _buffer: BufferNamespaceApi | undefined; constructor(options?: ITerminalOptions) { this._core = new TerminalCore(options); + this._addonManager = new AddonManager(); } private _checkProposedApi(): void { @@ -69,6 +72,7 @@ export class Terminal implements ITerminalApi { return this.registerMarker(cursorYOffset); } public dispose(): void { + this._addonManager.dispose(); this._core.dispose(); } public clear(): void { @@ -106,6 +110,10 @@ export class Terminal implements ITerminalApi { 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) { diff --git a/typings/xterm-core.d.ts b/typings/xterm-core.d.ts index 06964ca06..eabb51fcd 100644 --- a/typings/xterm-core.d.ts +++ b/typings/xterm-core.d.ts @@ -12,7 +12,7 @@ declare module 'xterm-core' { * A string representing log level. */ export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off'; - + /** * An object containing start up options for the terminal. */ @@ -23,7 +23,7 @@ declare module 'xterm-core' { * true currently, but will change to false in v5.0. */ allowProposedApi?: boolean; - + /** * Whether background should support non-opaque color. It must be set before * executing the `Terminal.open()` method and can't be changed later without @@ -31,23 +31,23 @@ declare module 'xterm-core' { * performance. */ allowTransparency?: boolean; - + /** * If enabled, alt + click will move the prompt cursor to position * underneath the mouse. The default is true. */ altClickMovesCursor?: boolean; - + /** * A data uri of the sound to use for the bell when `bellStyle = 'sound'`. */ bellSound?: string; - + /** * The type of the bell notification the terminal will use. */ bellStyle?: 'none' | 'sound'; - + /** * When enabled the cursor will be set to the beginning of the next line * with every new line. This is equivalent to sending '\r\n' for each '\n'. @@ -57,59 +57,59 @@ declare module 'xterm-core' { * useful. */ convertEol?: boolean; - + /** * The number of columns in the terminal. */ cols?: number; - + /** * Whether the cursor blinks. */ cursorBlink?: boolean; - + /** * The style of the cursor. */ cursorStyle?: 'block' | 'underline' | 'bar'; - + /** * The width of the cursor in CSS pixels when `cursorStyle` is set to 'bar'. */ cursorWidth?: number; - + /** * Whether input should be disabled. */ disableStdin?: boolean; - + /** * Whether to draw bold text in bright colors. The default is true. */ drawBoldTextInBrightColors?: boolean; - + /** * The modifier key hold to multiply scroll speed. */ fastScrollModifier?: 'alt' | 'ctrl' | 'shift' | undefined; - + /** * The spacing in whole pixels between characters. */ letterSpacing?: number; - + /** * The line height used to render text. */ lineHeight?: number; - + /** * The duration in milliseconds before link tooltip events fire when * hovering on a link. * @deprecated This will be removed when the link matcher API is removed. */ linkTooltipHoverDuration?: number; - + /** * What log level to use, this will log for all levels below and including * what is set: @@ -121,12 +121,12 @@ declare module 'xterm-core' { * 5. off */ logLevel?: LogLevel; - + /** * Whether to treat option as the meta key. */ macOptionIsMeta?: boolean; - + /** * Whether holding a modifier key will force normal selection behavior, * regardless of whether the terminal is in mouse events mode. This will @@ -135,7 +135,7 @@ declare module 'xterm-core' { * with mouse mode enabled. */ macOptionClickForcesSelection?: boolean; - + /** * The minimum contrast ratio for text in the terminal, setting this will * change the foreground color dynamically depending on whether the contrast @@ -147,47 +147,47 @@ declare module 'xterm-core' { * - 21: White on black or black on white. */ minimumContrastRatio?: number; - + /** * Whether to select the word under the cursor on right click, this is * standard behavior in a lot of macOS applications. */ rightClickSelectsWord?: boolean; - + /** * The number of rows in the terminal. */ rows?: number; - + /** * Whether screen reader support is enabled. When on this will expose * supporting elements in the DOM to support NVDA on Windows and VoiceOver * on macOS. */ screenReaderMode?: boolean; - + /** * The amount of scrollback in the terminal. Scrollback is the amount of * rows that are retained when lines are scrolled beyond the initial * viewport. */ scrollback?: number; - + /** * The scrolling speed multiplier used for adjusting normal scrolling speed. */ scrollSensitivity?: number; - + /** * The size of tab stops in the terminal. */ tabStopWidth?: number; - + /** * The color theme of the terminal. */ theme?: ITheme; - + /** * Whether "Windows mode" is enabled. Because Windows backends winpty and * conpty operate by doing line wrapping on their side, xterm.js does not @@ -199,20 +199,20 @@ declare module 'xterm-core' { * not whitespace. */ windowsMode?: boolean; - + /** * A string containing all characters that are considered word separated by the * double click to select work logic. */ wordSeparator?: string; - + /** * Enable various window manipulation and report features. * All features are disabled by default for security reasons. */ windowOptions?: IWindowOptions; } - + /** * Contains colors to theme the terminal with. */ @@ -260,14 +260,14 @@ declare module 'xterm-core' { /** ANSI bright white (eg. `\x1b[1;37m`) */ brightWhite?: string; } - + /** * An object that can be disposed via a dispose function. */ export interface IDisposable { dispose(): void; } - + /** * An event that can be listened to. * @returns an `IDisposable` to stop listening. @@ -275,7 +275,7 @@ declare module 'xterm-core' { export interface IEvent { (listener: (arg1: T, arg2: U) => any): IDisposable; } - + /** * Represents a specific line in the terminal that is tracked when scrollback * is trimmed and lines are added or removed. This is a single line that may @@ -286,18 +286,18 @@ declare module 'xterm-core' { * A unique identifier for this marker. */ readonly id: number; - + /** * Whether this marker is disposed. */ readonly isDisposed: boolean; - + /** * The actual line index in the buffer at this point in time. This is set to * -1 if the marker has been disposed. */ readonly line: number; - + /** * Event listener to get notified when the marker gets disposed. Automatic disposal * might happen for a marker, that got invalidated by scrolling out or removal of @@ -305,7 +305,7 @@ declare module 'xterm-core' { */ onDispose: IEvent; } - + /** * The set of localizable strings. */ @@ -314,14 +314,14 @@ declare module 'xterm-core' { * The aria label for the underlying input textarea for the terminal. */ promptLabel: string; - + /** * Announcement for when line reading is suppressed due to too many lines * being printed to the terminal when `screenReaderMode` is enabled. */ tooMuchOutput: string; } - + /** * Enable various window manipulation and report features (CSI Ps ; Ps ; Ps t). * @@ -477,7 +477,7 @@ declare module 'xterm-core' { */ setWinLines?: boolean; } - + /** * The class that represents an xterm.js terminal. */ @@ -488,51 +488,51 @@ declare module 'xterm-core' { * `Terminal.resize` for when the terminal exists. */ readonly rows: number; - + /** * The number of columns in the terminal's viewport. Use * `ITerminalOptions.cols` to set this in the constructor and * `Terminal.resize` for when the terminal exists. */ readonly cols: number; - + /** * (EXPERIMENTAL) The terminal's current buffer, this might be either the * normal buffer or the alt buffer depending on what's running in the * terminal. */ readonly buffer: IBufferNamespace; - + /** * (EXPERIMENTAL) Get all markers registered against the buffer. If the alt * buffer is active this will always return []. */ readonly markers: ReadonlyArray; - + /** * (EXPERIMENTAL) Get the parser interface to register * custom escape sequence handlers. */ readonly parser: IParser; - + /** * (EXPERIMENTAL) Get the Unicode handling interface * to register and switch Unicode version. */ readonly unicode: IUnicodeHandling; - + /** * Natural language strings that can be localized. */ static strings: ILocalizableStrings; - + /** * Creates a new `Terminal` object. * * @param options An object containing a set of options. */ constructor(options?: ITerminalOptions); - + /** * Adds an event listener for when a binary event fires. This is used to * enable non UTF-8 conformant binary messages to be sent to the backend. @@ -543,13 +543,13 @@ declare module 'xterm-core' { * @returns an `IDisposable` to stop listening. */ onBinary: IEvent; - + /** * Adds an event listener for the cursor moves. * @returns an `IDisposable` to stop listening. */ onCursorMove: IEvent; - + /** * Adds an event listener for when a data event fires. This happens for * example when the user types or pastes into the terminal. The event value @@ -558,20 +558,20 @@ declare module 'xterm-core' { * @returns an `IDisposable` to stop listening. */ onData: IEvent; - + /** * Adds an event listener for when a line feed is added. * @returns an `IDisposable` to stop listening. */ onLineFeed: IEvent; - + /** * Adds an event listener for when the terminal is resized. The event value * contains the new size. * @returns an `IDisposable` to stop listening. */ onResize: IEvent<{ cols: number, rows: number }>; - + /** * Adds an event listener for when an OSC 0 or OSC 2 title change occurs. * The event value is the new title. @@ -595,7 +595,7 @@ declare module 'xterm-core' { * @returns The new marker or undefined. */ registerMarker(cursorYOffset: number): IMarker | undefined; - + /** * @deprecated use `registerMarker` instead. */ @@ -611,7 +611,7 @@ declare module 'xterm-core' { * Clear the entire buffer, making the prompt line the new first line. */ clear(): void; - + /** * Write data to the terminal. * @param data The data to write to the terminal. This can either be raw @@ -621,7 +621,7 @@ declare module 'xterm-core' { * by the parser. */ write(data: string | Uint8Array, callback?: () => void): void; - + /** * Writes data to the terminal, followed by a break line character (\n). * @param data The data to write to the terminal. This can either be raw @@ -631,7 +631,7 @@ declare module 'xterm-core' { * by the parser. */ writeln(data: string | Uint8Array, callback?: () => void): void; - + /** * Write UTF8 data to the terminal. * @param data The data to write to the terminal. @@ -639,7 +639,7 @@ declare module 'xterm-core' { * @deprecated use `write` instead */ writeUtf8(data: Uint8Array, callback?: () => void): void; - + /** * Retrieves an option's value from the terminal. * @param key The option key. @@ -660,7 +660,7 @@ declare module 'xterm-core' { * @param key The option key. */ getOption(key: string): any; - + /** * Sets an option on the terminal. * @param key The option key. @@ -721,13 +721,19 @@ declare module 'xterm-core' { * @param value The option value. */ setOption(key: string, value: any): void; - + /** * Perform a full reset (RIS, aka '\x1bc'). */ reset(): void; + + /** + * Loads an addon into this instance of xterm.js. + * @param addon The addon to load. + */ + loadAddon(addon: ITerminalAddon): void; } - + /** * An addon that can provide additional functionality to the terminal. */ @@ -737,7 +743,7 @@ declare module 'xterm-core' { */ activate(terminal: Terminal): void; } - + /** * An object representing a selection within the terminal. */ @@ -746,23 +752,23 @@ declare module 'xterm-core' { * The start column of the selection. */ startColumn: number; - + /** * The start row of the selection. */ startRow: number; - + /** * The end column of the selection. */ endColumn: number; - + /** * The end row of the selection. */ endRow: number; } - + /** * An object representing a range within the viewport of the terminal. */ @@ -771,13 +777,13 @@ declare module 'xterm-core' { * The start of the range. */ start: IViewportRangePosition; - + /** * The end of the range. */ end: IViewportRangePosition; } - + /** * An object representing a cell position within the viewport of the terminal. */ @@ -790,14 +796,14 @@ declare module 'xterm-core' { * a text editor. */ x: number; - + /** * The y position of the cell. This is a 0-based index that refers to a * specific row. */ y: number; } - + /** * A range within a buffer. */ @@ -806,13 +812,13 @@ declare module 'xterm-core' { * The start position of the range. */ start: IBufferCellPosition; - + /** * The end position of the range. */ end: IBufferCellPosition; } - + /** * A position within a buffer. */ @@ -821,13 +827,13 @@ declare module 'xterm-core' { * The x position within the buffer. */ x: number; - + /** * The y position within the buffer. */ y: number; } - + /** * Represents a terminal buffer. */ @@ -836,36 +842,36 @@ declare module 'xterm-core' { * The type of the buffer. */ readonly type: 'normal' | 'alternate'; - + /** * The y position of the cursor. This ranges between `0` (when the * cursor is at baseY) and `Terminal.rows - 1` (when the cursor is on the * last row). */ readonly cursorY: number; - + /** * The x position of the cursor. This ranges between `0` (left side) and * `Terminal.cols` (after last cell of the row). */ readonly cursorX: number; - + /** * The line within the buffer where the top of the viewport is. */ readonly viewportY: number; - + /** * The line within the buffer where the top of the bottom page is (when * fully scrolled down). */ readonly baseY: number; - + /** * The amount of lines in the buffer. */ readonly length: number; - + /** * Gets a line from the buffer, or undefined if the line index does not * exist. @@ -877,7 +883,7 @@ declare module 'xterm-core' { * @param y The line index to get. */ getLine(y: number): IBufferLine | undefined; - + /** * Creates an empty cell object suitable as a cell reference in * `line.getCell(x, cell)`. Use this to avoid costly recreation of @@ -885,7 +891,7 @@ declare module 'xterm-core' { */ getNullCell(): IBufferCell; } - + /** * Represents the terminal's set of buffers. */ @@ -894,25 +900,25 @@ declare module 'xterm-core' { * The active buffer, this will either be the normal or alternate buffers. */ readonly active: IBuffer; - + /** * The normal buffer. */ readonly normal: IBuffer; - + /** * The alternate buffer, this becomes the active buffer when an application * enters this mode via DECSET (`CSI ? 4 7 h`) */ readonly alternate: IBuffer; - + /** * Adds an event listener for when the active buffer changes. * @returns an `IDisposable` to stop listening. */ onBufferChange: IEvent; } - + /** * Represents a line in the terminal's buffer. */ @@ -921,13 +927,13 @@ declare module 'xterm-core' { * Whether the line is wrapped from the previous line. */ readonly isWrapped: boolean; - + /** * The length of the line, all call to getCell beyond the length will result * in `undefined`. */ readonly length: number; - + /** * Gets a cell from the line, or undefined if the line index does not exist. * @@ -941,7 +947,7 @@ declare module 'xterm-core' { * looped over to avoid creating new objects for every cell. */ getCell(x: number, cell?: IBufferCell): IBufferCell | undefined; - + /** * Gets the line as a string. Note that this is gets only the string for the * line, not taking isWrapped into account. @@ -952,7 +958,7 @@ declare module 'xterm-core' { */ translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string; } - + /** * Represents a single cell in the terminal's buffer. */ @@ -965,7 +971,7 @@ declare module 'xterm-core' { * - `0` for cells immediately following cells with a width of `2`. */ getWidth(): number; - + /** * The character(s) within the cell. Examples of what this can contain: * @@ -974,13 +980,13 @@ declare module 'xterm-core' { * - An emoji */ getChars(): string; - + /** * Gets the UTF32 codepoint of single characters, if content is a combined * string it returns the codepoint of the last character in the string. */ getCode(): number; - + /** * Gets the number representation of the foreground color mode, this can be * used to perform quick comparisons of 2 cells to see if they're the same. @@ -988,7 +994,7 @@ declare module 'xterm-core' { * a cell is. */ getFgColorMode(): number; - + /** * Gets the number representation of the background color mode, this can be * used to perform quick comparisons of 2 cells to see if they're the same. @@ -996,7 +1002,7 @@ declare module 'xterm-core' { * a cell is. */ getBgColorMode(): number; - + /** * Gets a cell's foreground color number, this differs depending on what the * color mode of the cell is: @@ -1009,7 +1015,7 @@ declare module 'xterm-core' { * (CSI 3 8 ; 2 ; Pi ; Pr ; Pg ; Pb) */ getFgColor(): number; - + /** * Gets a cell's background color number, this differs depending on what the * color mode of the cell is: @@ -1022,7 +1028,7 @@ declare module 'xterm-core' { * (CSI 4 8 ; 2 ; Pi ; Pr ; Pg ; Pb) */ getBgColor(): number; - + /** Whether the cell has the bold attribute (CSI 1 m). */ isBold(): number; /** Whether the cell has the inverse attribute (CSI 3 m). */ @@ -1037,7 +1043,7 @@ declare module 'xterm-core' { isInverse(): number; /** Whether the cell has the inverse attribute (CSI 8 m). */ isInvisible(): number; - + /** Whether the cell is using the RGB foreground color mode. */ isFgRGB(): boolean; /** Whether the cell is using the RGB background color mode. */ @@ -1050,11 +1056,11 @@ declare module 'xterm-core' { isFgDefault(): boolean; /** Whether the cell is using the default background color mode. */ isBgDefault(): boolean; - + /** Whether the cell has the default attribute (no color or style). */ isAttributeDefault(): boolean; } - + /** * Data type to register a CSI, DCS or ESC callback in the parser * in the form: @@ -1098,7 +1104,7 @@ declare module 'xterm-core' { */ final: string; } - + /** * Allows hooking into the parser for custom handling of escape sequences. */ @@ -1116,7 +1122,7 @@ declare module 'xterm-core' { * @return An IDisposable you can call to remove this handler. */ registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable; - + /** * Adds a handler for DCS escape sequences. * @param id Specifies the function identifier under which the callback @@ -1135,7 +1141,7 @@ declare module 'xterm-core' { * @return An IDisposable you can call to remove this handler. */ registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable; - + /** * Adds a handler for ESC escape sequences. * @param id Specifies the function identifier under which the callback @@ -1148,7 +1154,7 @@ declare module 'xterm-core' { * @return An IDisposable you can call to remove this handler. */ registerEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable; - + /** * Adds a handler for OSC escape sequences. * @param ident The number (first parameter) of the sequence. @@ -1167,7 +1173,7 @@ declare module 'xterm-core' { */ registerOscHandler(ident: number, callback: (data: string) => boolean): IDisposable; } - + /** * (EXPERIMENTAL) Unicode version provider. * Used to register custom Unicode versions with `Terminal.unicode.register`. @@ -1177,13 +1183,13 @@ declare module 'xterm-core' { * String indicating the Unicode version provided. */ readonly version: string; - + /** * Unicode version dependent wcwidth implementation. */ wcwidth(codepoint: number): 0 | 1 | 2; } - + /** * (EXPERIMENTAL) Unicode handling interface. */ @@ -1192,16 +1198,15 @@ declare module 'xterm-core' { * Register a custom Unicode version provider. */ register(provider: IUnicodeVersionProvider): void; - + /** * Registered Unicode versions. */ readonly versions: ReadonlyArray; - + /** * Getter/setter for active Unicode version. */ activeVersion: string; } } - \ No newline at end of file From 3b8218e36e5da16c9724c7b812672879a3779b3e Mon Sep 17 00:00:00 2001 From: meganrogge Date: Tue, 10 Aug 2021 10:03:38 -0700 Subject: [PATCH 045/164] work with Daniel --- src/browser/renderer/BaseRenderLayer.ts | 45 +++++++++++-------- ...Characters.ts => BoxAndBlockCharacters.ts} | 0 src/common/CoreTerminal.ts | 11 +++++ 3 files changed, 38 insertions(+), 18 deletions(-) rename src/browser/renderer/{BoxCharacters.ts => BoxAndBlockCharacters.ts} (100%) diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 188816ec9..e6ad0af05 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -17,7 +17,7 @@ import { IBufferService, IOptionsService } from 'common/services/Services'; import { throwIfFalsy } from 'browser/renderer/RendererUtils'; import { channels, color, rgba } from 'browser/Color'; import { removeElementFromParent } from 'browser/Dom'; -import { boxDrawingBoxes, boxDrawingLineSegments } from 'browser/renderer/BoxCharacters'; +import { boxDrawingBoxes, boxDrawingLineSegments } from 'browser/renderer/BoxAndBlockCharacters'; export abstract class BaseRenderLayer implements IRenderLayer { private _canvas: HTMLCanvasElement; @@ -395,18 +395,16 @@ export abstract class BaseRenderLayer implements IRenderLayer { this._ctx.strokeStyle = this._ctx.fillStyle; const xOffset = x * this._scaledCellWidth + this._scaledCharLeft; const yOffset = y * this._scaledCellHeight + this._scaledCharTop; - const xEighth = this._scaledCellWidth / 8; - const yEighth = this._scaledCellHeight / 8; - for (let i = 0; i < boxes.length; i++) { const box = boxes[i]; + const xEighth = this._scaledCellWidth / 8; + const yEighth = this._scaledCellHeight / 8; this._ctx.fillRect( - xOffset + (box.x*xEighth), - yOffset + (box.y*yEighth), - (box.w * xEighth), - (box.h * yEighth)); + xOffset, + yOffset, + box.w * xEighth, + box.h * yEighth); } - return true; } @@ -418,28 +416,30 @@ export abstract class BaseRenderLayer implements IRenderLayer { // TODO: Clean below const scale = window.devicePixelRatio; this._ctx.strokeStyle = this._ctx.fillStyle; - this._ctx.lineWidth = scale; + + // increase # of pixels when font size incremented by 10 + this._ctx.lineWidth = Math.max(Math.floor(this._optionsService.options.fontSize / 10), 1); const xOffset = x * this._scaledCellWidth + this._scaledCharLeft; const yOffset = y * this._scaledCellHeight + this._scaledCharTop; - const horizontalCenter = this._scaledCellWidth / 2; - const verticalCenter = this._scaledCellHeight / 2; + const horizontalCenter = Math.round(this._scaledCellWidth / 2); + const verticalCenter = Math.round(this._scaledCellHeight / 2); const xPoints = [ xOffset, + xOffset + horizontalCenter - scale * 2, xOffset + horizontalCenter - scale, - xOffset + horizontalCenter - scale / 2, xOffset + horizontalCenter, - xOffset + horizontalCenter + scale / 2, xOffset + horizontalCenter + scale, + xOffset + horizontalCenter + scale * 2, xOffset + this._scaledCellWidth ]; const yPoints = [ yOffset, + yOffset + verticalCenter - scale * 2, yOffset + verticalCenter - scale, - yOffset + verticalCenter - scale / 2, yOffset + verticalCenter, - yOffset + verticalCenter + scale / 2, yOffset + verticalCenter + scale, + yOffset + verticalCenter + scale * 2, yOffset + this._scaledCellHeight ]; @@ -448,7 +448,12 @@ export abstract class BaseRenderLayer implements IRenderLayer { if (i === 0 || (op.x1 !== ops[i - 1].x2 || op.y1 !== ops[i - 1].y2)) { this._ctx.beginPath(); - this._ctx.moveTo(xPoints[op.x1], yPoints[op.y1]); + if (this._ctx.lineWidth % 2 === 1) { + + this._ctx.moveTo(op.x1 === 0 ? xPoints[op.x1] : xPoints[op.x1] + .5, yPoints[op.y1] + .5); + } else { + this._ctx.moveTo(xPoints[op.x1], yPoints[op.y1]); + } } if (typeof op.cx1 !== 'undefined') { @@ -462,7 +467,11 @@ export abstract class BaseRenderLayer implements IRenderLayer { yPoints[op.y2]); } else { // Draw line - this._ctx.lineTo(xPoints[op.x2], yPoints[op.y2]); + if (this._ctx.lineWidth % 2 === 1) { + this._ctx.lineTo(op.x2 === 0 ? xPoints[op.x2] : xPoints[op.x2] + .5, yPoints[op.y2] + .5); + } else { + this._ctx.lineTo(xPoints[op.x2], yPoints[op.y2]); + } } this._ctx.stroke(); diff --git a/src/browser/renderer/BoxCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts similarity index 100% rename from src/browser/renderer/BoxCharacters.ts rename to src/browser/renderer/BoxAndBlockCharacters.ts diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index e61a8e16e..14b08abd1 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -132,6 +132,17 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { // Setup WriteBuffer this._writeBuffer = new WriteBuffer((data, promiseResult) => this._inputHandler.parse(data, promiseResult)); + setTimeout(() => { + this.write('─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏\r\n'); + this.write('┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟\r\n'); + this.write('┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯\r\n'); + this.write('┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿\r\n'); + this.write('╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╌ ╍ ╎ ╏\r\n'); + this.write('═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟\r\n'); + this.write('╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯\r\n'); + this.write('╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\r\n'); + this.write('└─┐╘═╕╚═╕╗'); + }, 1500); } public dispose(): void { From f769d03e0c32ee1155ecdcf956b7b8b9ca8e3654 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 10 Aug 2021 12:27:43 -0700 Subject: [PATCH 046/164] xterm-core -> xterm-headless --- node-test/README.md | 2 +- node-test/index.js | 2 +- package.json | 1 + src/headless/public/Terminal.ts | 2 +- src/headless/tsconfig.json | 2 +- .../{xterm-core.d.ts => xterm-headless.d.ts} | 2 +- webpack.config.core.js | 41 ------------------- webpack.config.headless.js | 8 ++-- 8 files changed, 10 insertions(+), 50 deletions(-) rename typings/{xterm-core.d.ts => xterm-headless.d.ts} (99%) delete mode 100644 webpack.config.core.js diff --git a/node-test/README.md b/node-test/README.md index 0da501461..cd3468488 100644 --- a/node-test/README.md +++ b/node-test/README.md @@ -1,4 +1,4 @@ -Cursory test that 'xterm-core' works: +Cursory test that 'xterm-headless' works: ``` # From root of this repo diff --git a/node-test/index.js b/node-test/index.js index 2fd8da7f9..55359c8eb 100644 --- a/node-test/index.js +++ b/node-test/index.js @@ -2,7 +2,7 @@ import { createRequire } from 'module'; const require = createRequire(import.meta.url); const Terminal = require('../lib-headless/xterm.js').Terminal; -console.log('Creating xterm-core terminal...'); +console.log('Creating xterm-headless terminal...'); const terminal = new Terminal(); console.log('Writing to terminal...') terminal.write('foo \x1b[1;31mbar\x1b[0m baz', () => { diff --git a/package.json b/package.json index 47fd0a894..beffc66bf 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "scripts": { "prepackage": "npm run build", "package": "webpack", + "package-headless": "webpack --config ./webpack.config.headless.js", "compile": "tsc -b ./src/common/public/tsconfig.json", "start": "node demo/start", "start-debug": "node --inspect-brk demo/start", diff --git a/src/headless/public/Terminal.ts b/src/headless/public/Terminal.ts index 44f9753a2..f14bdd559 100644 --- a/src/headless/public/Terminal.ts +++ b/src/headless/public/Terminal.ts @@ -7,7 +7,7 @@ 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, IParser, ITerminalAddon, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-core'; +import { IBufferNamespace as IBufferNamespaceApi, IMarker, IParser, ITerminalAddon, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-headless'; import { Terminal as TerminalCore } from 'headless/Terminal'; import { AddonManager } from 'common/public/AddonManager'; diff --git a/src/headless/tsconfig.json b/src/headless/tsconfig.json index 6085a07f2..b579af97c 100644 --- a/src/headless/tsconfig.json +++ b/src/headless/tsconfig.json @@ -18,7 +18,7 @@ "include": [ "./**/*", "../../typings/xterm.d.ts", // common/Types.d.ts imports from 'xterm' - "../../typings/xterm-core.d.ts" + "../../typings/xterm-headless.d.ts" ], "references": [ { "path": "../common" } diff --git a/typings/xterm-core.d.ts b/typings/xterm-headless.d.ts similarity index 99% rename from typings/xterm-core.d.ts rename to typings/xterm-headless.d.ts index eabb51fcd..3dd9d69e1 100644 --- a/typings/xterm-core.d.ts +++ b/typings/xterm-headless.d.ts @@ -7,7 +7,7 @@ * to be stable and consumed by external programs. */ -declare module 'xterm-core' { +declare module 'xterm-headless' { /** * A string representing log level. */ diff --git a/webpack.config.core.js b/webpack.config.core.js deleted file mode 100644 index 85c37ff12..000000000 --- a/webpack.config.core.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) 2019 The xterm.js authors. All rights reserved. - * @license MIT - */ - -const path = require('path'); - -/** - * This webpack config does a production build for xterm-core.js. It works by taking the output from tsc - * (via `yarn watch` or `yarn prebuild`) which are put into `xterm-core/` and webpacks them into a - * production mode commonjs library module in `lib/`. The aliases are used fix up the absolute paths - * output by tsc (because of `baseUrl` and `paths` in `tsconfig.json`. - */ -module.exports = { - entry: './xterm-core/common/public/Terminal.js', - devtool: 'source-map', - module: { - rules: [ - { - test: /\.js$/, - use: ["source-map-loader"], - enforce: "pre", - exclude: /node_modules/ - } - ] - }, - resolve: { - modules: ['./node_modules'], - extensions: [ '.js' ], - alias: { - common: path.resolve('./xterm-core/common') - } - }, - output: { - filename: 'xterm-core.js', - path: path.resolve('./lib'), - libraryTarget: 'commonjs' - }, - mode: 'production', - target: 'node', -}; diff --git a/webpack.config.headless.js b/webpack.config.headless.js index 7ae666761..805b9a3e2 100644 --- a/webpack.config.headless.js +++ b/webpack.config.headless.js @@ -6,10 +6,10 @@ const path = require('path'); /** - * This webpack config does a production build for xterm.js. It works by taking the output from tsc - * (via `yarn watch` or `yarn prebuild`) which are put into `out/` and webpacks them into a - * production mode umd library module in `lib/`. The aliases are used fix up the absolute paths - * output by tsc (because of `baseUrl` and `paths` in `tsconfig.json`. + * This webpack config does a production build for xterm.js headless. It works by taking the output + * from tsc (via `yarn watch` or `yarn prebuild`) which are put into `out/` and webpacks them into a + * production mode umd library module in `lib-headless/`. The aliases are used fix up the absolute + * paths output by tsc (because of `baseUrl` and `paths` in `tsconfig.json`. */ module.exports = { entry: './out/headless/public/Terminal.js', From 4a200e59acc6e655e05e78767cbbae5f3a5318fb Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 10 Aug 2021 12:50:22 -0700 Subject: [PATCH 047/164] Create headless package script --- bin/package_headless.js | 40 ++++++++++++++++++++++++++++++++++++++++ headless/.gitignore | 2 ++ headless/README.md | 5 +++++ 3 files changed, 47 insertions(+) create mode 100644 bin/package_headless.js create mode 100644 headless/.gitignore create mode 100644 headless/README.md diff --git a/bin/package_headless.js b/bin/package_headless.js new file mode 100644 index 000000000..276132007 --- /dev/null +++ b/bin/package_headless.js @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2021 The xterm.js authors. All rights reserved. + * @license MIT + */ + +const fs = require('fs'); +const { join } = require('path'); + +const repoRoot = join(__dirname, '..'); +const headlessRoot = join(repoRoot, 'headless'); + +// Create headless/package.json +console.log('> Creating headless/package.json'); +const xtermPackageJson = require('../package.json'); +const xtermHeadlessPackageJson = { + ...xtermPackageJson, + name: 'xterm-headless', + description: 'A headless terminal component that runs in Node.js', + main: 'lib/xterm-headless.js', + types: 'typings/xterm-headless.d.ts', +}; +delete xtermHeadlessPackageJson['scripts']; +delete xtermHeadlessPackageJson['devDependencies']; +delete xtermHeadlessPackageJson['style']; +xtermHeadlessPackageJson.version += '-alpha'; +fs.writeFileSync(join(headlessRoot, 'package.json'), JSON.stringify(xtermHeadlessPackageJson, null, 1)); +console.log(fs.readFileSync(join(headlessRoot, 'package.json')).toString()); + +console.log('> Creating headless/typings'); +mkdirF(join(headlessRoot, 'typings')); +fs.copyFileSync( + join(repoRoot, 'typings/xterm-headless.d.ts'), + join(headlessRoot, 'typings/xterm-headless.d.ts') +); + +function mkdirF(p) { + if (!fs.existsSync(p)) { + fs.mkdirSync(p); + } +} diff --git a/headless/.gitignore b/headless/.gitignore new file mode 100644 index 000000000..9b8b27497 --- /dev/null +++ b/headless/.gitignore @@ -0,0 +1,2 @@ +typings/ +package.json diff --git a/headless/README.md b/headless/README.md new file mode 100644 index 000000000..de22b47a1 --- /dev/null +++ b/headless/README.md @@ -0,0 +1,5 @@ +# [![xterm.js logo](../logo-full.png)](https://xtermjs.org) + +⚠ This package is a work in progress + +`xterm-headless` is a headless terminal that can be run in node.js. This is useful in combination with the frontend [`xterm`](https://www.npmjs.com/package/xterm) for example to keep track of a terminal's state on a remote server where the process is hosted. From 15bd827c2ee6c516a32b05dcdd7652db76d26b69 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 10 Aug 2021 12:57:45 -0700 Subject: [PATCH 048/164] Improve headless packaging --- .gitignore | 1 - bin/package_headless.js | 2 +- headless/.gitignore | 1 + package.json | 1 + webpack.config.headless.js | 2 +- 5 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 4958559ee..8aea04b2e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ node_modules/ *.swp .lock-wscript lib/ -lib-headless/ out/ out-test/ .nyc_output/ diff --git a/bin/package_headless.js b/bin/package_headless.js index 276132007..104844e2f 100644 --- a/bin/package_headless.js +++ b/bin/package_headless.js @@ -16,7 +16,7 @@ const xtermHeadlessPackageJson = { ...xtermPackageJson, name: 'xterm-headless', description: 'A headless terminal component that runs in Node.js', - main: 'lib/xterm-headless.js', + main: 'lib-headless/xterm-headless.js', types: 'typings/xterm-headless.d.ts', }; delete xtermHeadlessPackageJson['scripts']; diff --git a/headless/.gitignore b/headless/.gitignore index 9b8b27497..4aba0be59 100644 --- a/headless/.gitignore +++ b/headless/.gitignore @@ -1,2 +1,3 @@ +lib-headless/ typings/ package.json diff --git a/package.json b/package.json index beffc66bf..2d128b08e 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "prepackage": "npm run build", "package": "webpack", "package-headless": "webpack --config ./webpack.config.headless.js", + "postpackage-headless": "node ./bin/package_headless.js", "compile": "tsc -b ./src/common/public/tsconfig.json", "start": "node demo/start", "start-debug": "node --inspect-brk demo/start", diff --git a/webpack.config.headless.js b/webpack.config.headless.js index 805b9a3e2..2fe759155 100644 --- a/webpack.config.headless.js +++ b/webpack.config.headless.js @@ -34,7 +34,7 @@ module.exports = { }, output: { filename: 'xterm.js', - path: path.resolve('./lib-headless'), + path: path.resolve('./headless/lib-headless'), library: { type: 'commonjs' } From 6aa0782ce34fa02171d09b9b1df4d33d012e3018 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 10 Aug 2021 13:14:05 -0700 Subject: [PATCH 049/164] Publish dry run in package_headless --- bin/package_headless.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bin/package_headless.js b/bin/package_headless.js index 104844e2f..37d846dfe 100644 --- a/bin/package_headless.js +++ b/bin/package_headless.js @@ -3,6 +3,7 @@ * @license MIT */ +const { spawn, exec } = require('child_process'); const fs = require('fs'); const { join } = require('path'); @@ -38,3 +39,15 @@ function mkdirF(p) { fs.mkdirSync(p); } } + +console.log('> Publish dry run'); +exec('npm publish --dry-run', { cwd: headlessRoot }, (error, stdout, stderr) => { + if (error) { + console.log(`error: ${error.message}`); + return; + } + if (stderr) { + console.error(`stderr:\n${stderr}`); + } + console.log(`stdout:\n${stdout}`); +}); From ee759e245dee465b4bad879ae65fe7d99bd8fd40 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Tue, 10 Aug 2021 13:41:03 -0700 Subject: [PATCH 050/164] line up vertically --- src/browser/renderer/BaseRenderLayer.ts | 35 ++++++++++++------------- src/common/CoreTerminal.ts | 7 ++++- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index e6ad0af05..aefc0369d 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -408,8 +408,8 @@ export abstract class BaseRenderLayer implements IRenderLayer { return true; } - const ops = boxDrawingLineSegments[char]; - if (!ops) { + const lineSegments = boxDrawingLineSegments[char]; + if (!lineSegments) { return false; } @@ -434,7 +434,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { xOffset + this._scaledCellWidth ]; const yPoints = [ - yOffset, + yOffset - 1, yOffset + verticalCenter - scale * 2, yOffset + verticalCenter - scale, yOffset + verticalCenter, @@ -443,34 +443,33 @@ export abstract class BaseRenderLayer implements IRenderLayer { yOffset + this._scaledCellHeight ]; - for (let i = 0; i < ops.length; i++) { - const op = ops[i]; + for (let i = 0; i < lineSegments.length; i++) { + const line = lineSegments[i]; - if (i === 0 || (op.x1 !== ops[i - 1].x2 || op.y1 !== ops[i - 1].y2)) { + if (i === 0 || (line.x1 !== lineSegments[i - 1].x2 || line.y1 !== lineSegments[i - 1].y2)) { this._ctx.beginPath(); if (this._ctx.lineWidth % 2 === 1) { - - this._ctx.moveTo(op.x1 === 0 ? xPoints[op.x1] : xPoints[op.x1] + .5, yPoints[op.y1] + .5); + this._ctx.moveTo(line.x1 === 0 ? xPoints[line.x1] : xPoints[line.x1] + .5, yPoints[line.y1] + .5); } else { - this._ctx.moveTo(xPoints[op.x1], yPoints[op.y1]); + this._ctx.moveTo(xPoints[line.x1], yPoints[line.y1]); } } - if (typeof op.cx1 !== 'undefined') { + if (typeof line.cx1 !== 'undefined') { // Draw curve this._ctx.bezierCurveTo( - xPoints[op.cx1], - yPoints[op.cy1], - xPoints[op.cx2], - yPoints[op.cy2], - xPoints[op.x2], - yPoints[op.y2]); + xPoints[line.cx1], + yPoints[line.cy1], + xPoints[line.cx2], + yPoints[line.cy2], + xPoints[line.x2], + yPoints[line.y2]); } else { // Draw line if (this._ctx.lineWidth % 2 === 1) { - this._ctx.lineTo(op.x2 === 0 ? xPoints[op.x2] : xPoints[op.x2] + .5, yPoints[op.y2] + .5); + this._ctx.lineTo(line.x2 === 0 ? xPoints[line.x2] : xPoints[line.x2] + .5, yPoints[line.y2] + .5); } else { - this._ctx.lineTo(xPoints[op.x2], yPoints[op.y2]); + this._ctx.lineTo(xPoints[line.x2], yPoints[line.y2]); } } diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 14b08abd1..5758957e1 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -141,7 +141,12 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { this.write('═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟\r\n'); this.write('╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯\r\n'); this.write('╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\r\n'); - this.write('└─┐╘═╕╚═╕╗'); + this.write('▇▇▇▇▇▇▇▇▇'); + this.write(' ╔═════════════════════════════════════════════════════════╕\r\n'); + this.write(' ║ │\r\n'); + this.write(' ║ ╔═══════════════╦════════╤════════╗ │\r\n'); + this.write(' ║ ║ ║ │ ║ │\r\n'); + this.write(' ║ ║ ║ │ ║ │\r\n'); }, 1500); } From 69ce01c794e965847bfaea4747318a62e0856e68 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Aug 2021 22:58:26 +0000 Subject: [PATCH 051/164] Bump path-parse from 1.0.6 to 1.0.7 Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index ee0f0558c..571f8a90f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3356,9 +3356,9 @@ path-key@^3.0.0, path-key@^3.1.0: integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== path-parse@^1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" - integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== + version "1.0.7" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" + integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== path-to-regexp@0.1.7: version "0.1.7" From 83ddf0fc4bf299507002f00bc88743c2e538ebd7 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 11 Aug 2021 04:46:27 -0700 Subject: [PATCH 052/164] Force publish of headless even in PR --- bin/publish.js | 8 ++++++-- node-test/index.js | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/publish.js b/bin/publish.js index 64336fdc7..fc4ad99cc 100644 --- a/bin/publish.js +++ b/bin/publish.js @@ -6,6 +6,7 @@ const cp = require('child_process'); const fs = require('fs'); const os = require('os'); +const { basename } = require('path'); const path = require('path'); // Setup auth @@ -22,6 +23,7 @@ const changedFiles = getChangedFilesInCommit('HEAD'); let isStableRelease = false; if (changedFiles.some(e => e.search(/^addons\//) === -1)) { isStableRelease = checkAndPublishPackage(path.resolve(__dirname, '..')); + checkAndPublishPackage(path.resolve(__dirname, '../headless')); } // Publish addons if any files were changed inside of the addon @@ -70,11 +72,13 @@ function checkAndPublishPackage(packageDir) { // Publish const args = ['publish']; - if (!isStableRelease) { + if (basename(packageDir) === 'headless') { + args.push('--tag', 'beta'); + } else if (!isStableRelease) { args.push('--tag', 'beta'); } console.log(`Spawn: npm ${args.join(' ')}`); - if (!isDryRun) { + if (!isDryRun || basename(packageDir) === 'headless') { const result = cp.spawnSync('npm', args, { cwd: packageDir, stdio: 'inherit' diff --git a/node-test/index.js b/node-test/index.js index 55359c8eb..021f2ecd4 100644 --- a/node-test/index.js +++ b/node-test/index.js @@ -1,6 +1,6 @@ import { createRequire } from 'module'; const require = createRequire(import.meta.url); -const Terminal = require('../lib-headless/xterm.js').Terminal; +const Terminal = require('../headless/lib-headless/xterm.js').Terminal; console.log('Creating xterm-headless terminal...'); const terminal = new Terminal(); From f685d8eb21263732cbb4e3c6941ae2851b6c68be Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 11 Aug 2021 04:52:37 -0700 Subject: [PATCH 053/164] Force publish --- azure-pipelines.yml | 2 +- bin/publish.js | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f4220176e..0cd932df7 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -145,7 +145,7 @@ jobs: - Linux_IntegrationTests - macOS_IntegrationTests - Windows_IntegrationTests - condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['FORCE_RELEASE'], 'true'))) + # condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['FORCE_RELEASE'], 'true'))) pool: vmImage: 'ubuntu-16.04' steps: diff --git a/bin/publish.js b/bin/publish.js index fc4ad99cc..357e28920 100644 --- a/bin/publish.js +++ b/bin/publish.js @@ -22,20 +22,20 @@ const changedFiles = getChangedFilesInCommit('HEAD'); // Publish xterm if any files were changed outside of the addons directory let isStableRelease = false; if (changedFiles.some(e => e.search(/^addons\//) === -1)) { - isStableRelease = checkAndPublishPackage(path.resolve(__dirname, '..')); + // isStableRelease = checkAndPublishPackage(path.resolve(__dirname, '..')); checkAndPublishPackage(path.resolve(__dirname, '../headless')); } // Publish addons if any files were changed inside of the addon const addonPackageDirs = [ - path.resolve(__dirname, '../addons/xterm-addon-attach'), - path.resolve(__dirname, '../addons/xterm-addon-fit'), - path.resolve(__dirname, '../addons/xterm-addon-ligatures'), - path.resolve(__dirname, '../addons/xterm-addon-search'), - path.resolve(__dirname, '../addons/xterm-addon-serialize'), - path.resolve(__dirname, '../addons/xterm-addon-unicode11'), - path.resolve(__dirname, '../addons/xterm-addon-web-links'), - path.resolve(__dirname, '../addons/xterm-addon-webgl') + // path.resolve(__dirname, '../addons/xterm-addon-attach'), + // path.resolve(__dirname, '../addons/xterm-addon-fit'), + // path.resolve(__dirname, '../addons/xterm-addon-ligatures'), + // path.resolve(__dirname, '../addons/xterm-addon-search'), + // path.resolve(__dirname, '../addons/xterm-addon-serialize'), + // path.resolve(__dirname, '../addons/xterm-addon-unicode11'), + // path.resolve(__dirname, '../addons/xterm-addon-web-links'), + // path.resolve(__dirname, '../addons/xterm-addon-webgl') ]; console.log(`Checking if addons need to be published`); for (const p of addonPackageDirs) { @@ -48,7 +48,7 @@ for (const p of addonPackageDirs) { // Publish website if it's a stable release if (isStableRelease) { - updateWebsite(); + // updateWebsite(); } function checkAndPublishPackage(packageDir) { @@ -72,11 +72,11 @@ function checkAndPublishPackage(packageDir) { // Publish const args = ['publish']; - if (basename(packageDir) === 'headless') { - args.push('--tag', 'beta'); - } else if (!isStableRelease) { - args.push('--tag', 'beta'); - } + args.push('--tag', 'beta'); + // if (basename(packageDir) === 'headless') { + // } else if (!isStableRelease) { + // args.push('--tag', 'beta'); + // } console.log(`Spawn: npm ${args.join(' ')}`); if (!isDryRun || basename(packageDir) === 'headless') { const result = cp.spawnSync('npm', args, { From 97fa4a59b700f25f244a20dc8d2beaad1c790fca Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 11 Aug 2021 05:54:37 -0700 Subject: [PATCH 054/164] Package headless in release step --- azure-pipelines.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0cd932df7..95a97e591 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -164,5 +164,7 @@ jobs: displayName: Cache node modules - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' + - script: node ./bin/package_headless.js + displayName: 'Package xterm-headless' - script: NPM_AUTH_TOKEN="$(NPM_AUTH_TOKEN)" node ./bin/publish.js displayName: 'Package and publish to npm' From b6e54307025be84c5eaf7230783cded7a028374f Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 11 Aug 2021 06:04:48 -0700 Subject: [PATCH 055/164] Revert "Force publish" This reverts commit f685d8eb21263732cbb4e3c6941ae2851b6c68be. --- azure-pipelines.yml | 2 +- bin/publish.js | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 95a97e591..c87496b2b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -145,7 +145,7 @@ jobs: - Linux_IntegrationTests - macOS_IntegrationTests - Windows_IntegrationTests - # condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['FORCE_RELEASE'], 'true'))) + condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['FORCE_RELEASE'], 'true'))) pool: vmImage: 'ubuntu-16.04' steps: diff --git a/bin/publish.js b/bin/publish.js index 357e28920..fc4ad99cc 100644 --- a/bin/publish.js +++ b/bin/publish.js @@ -22,20 +22,20 @@ const changedFiles = getChangedFilesInCommit('HEAD'); // Publish xterm if any files were changed outside of the addons directory let isStableRelease = false; if (changedFiles.some(e => e.search(/^addons\//) === -1)) { - // isStableRelease = checkAndPublishPackage(path.resolve(__dirname, '..')); + isStableRelease = checkAndPublishPackage(path.resolve(__dirname, '..')); checkAndPublishPackage(path.resolve(__dirname, '../headless')); } // Publish addons if any files were changed inside of the addon const addonPackageDirs = [ - // path.resolve(__dirname, '../addons/xterm-addon-attach'), - // path.resolve(__dirname, '../addons/xterm-addon-fit'), - // path.resolve(__dirname, '../addons/xterm-addon-ligatures'), - // path.resolve(__dirname, '../addons/xterm-addon-search'), - // path.resolve(__dirname, '../addons/xterm-addon-serialize'), - // path.resolve(__dirname, '../addons/xterm-addon-unicode11'), - // path.resolve(__dirname, '../addons/xterm-addon-web-links'), - // path.resolve(__dirname, '../addons/xterm-addon-webgl') + path.resolve(__dirname, '../addons/xterm-addon-attach'), + path.resolve(__dirname, '../addons/xterm-addon-fit'), + path.resolve(__dirname, '../addons/xterm-addon-ligatures'), + path.resolve(__dirname, '../addons/xterm-addon-search'), + path.resolve(__dirname, '../addons/xterm-addon-serialize'), + path.resolve(__dirname, '../addons/xterm-addon-unicode11'), + path.resolve(__dirname, '../addons/xterm-addon-web-links'), + path.resolve(__dirname, '../addons/xterm-addon-webgl') ]; console.log(`Checking if addons need to be published`); for (const p of addonPackageDirs) { @@ -48,7 +48,7 @@ for (const p of addonPackageDirs) { // Publish website if it's a stable release if (isStableRelease) { - // updateWebsite(); + updateWebsite(); } function checkAndPublishPackage(packageDir) { @@ -72,11 +72,11 @@ function checkAndPublishPackage(packageDir) { // Publish const args = ['publish']; - args.push('--tag', 'beta'); - // if (basename(packageDir) === 'headless') { - // } else if (!isStableRelease) { - // args.push('--tag', 'beta'); - // } + if (basename(packageDir) === 'headless') { + args.push('--tag', 'beta'); + } else if (!isStableRelease) { + args.push('--tag', 'beta'); + } console.log(`Spawn: npm ${args.join(' ')}`); if (!isDryRun || basename(packageDir) === 'headless') { const result = cp.spawnSync('npm', args, { From 5affa70097e154dc56118302942428e891331c2d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 11 Aug 2021 06:06:06 -0700 Subject: [PATCH 056/164] Undo headless force publish changes --- bin/publish.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bin/publish.js b/bin/publish.js index fc4ad99cc..aaf9cac0c 100644 --- a/bin/publish.js +++ b/bin/publish.js @@ -72,13 +72,11 @@ function checkAndPublishPackage(packageDir) { // Publish const args = ['publish']; - if (basename(packageDir) === 'headless') { - args.push('--tag', 'beta'); - } else if (!isStableRelease) { + if (!isStableRelease) { args.push('--tag', 'beta'); } console.log(`Spawn: npm ${args.join(' ')}`); - if (!isDryRun || basename(packageDir) === 'headless') { + if (!isDryRun) { const result = cp.spawnSync('npm', args, { cwd: packageDir, stdio: 'inherit' From 3e9b1bafbe5c4771165f3cb23bf38e99487a76b7 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 11 Aug 2021 06:10:12 -0700 Subject: [PATCH 057/164] Remove force publish changes --- bin/publish.js | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/publish.js b/bin/publish.js index aaf9cac0c..3c729f6c1 100644 --- a/bin/publish.js +++ b/bin/publish.js @@ -6,7 +6,6 @@ const cp = require('child_process'); const fs = require('fs'); const os = require('os'); -const { basename } = require('path'); const path = require('path'); // Setup auth From 370d0c562ad059961bfa62147c455e8592a80985 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 11 Aug 2021 06:19:53 -0700 Subject: [PATCH 058/164] Copy logo-full.png --- bin/package_headless.js | 15 ++++++++++----- headless/.gitignore | 1 + headless/README.md | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bin/package_headless.js b/bin/package_headless.js index 37d846dfe..0d4170df8 100644 --- a/bin/package_headless.js +++ b/bin/package_headless.js @@ -3,15 +3,14 @@ * @license MIT */ -const { spawn, exec } = require('child_process'); +const { exec } = require('child_process'); const fs = require('fs'); const { join } = require('path'); const repoRoot = join(__dirname, '..'); const headlessRoot = join(repoRoot, 'headless'); -// Create headless/package.json -console.log('> Creating headless/package.json'); +console.log('> headless/package.json'); const xtermPackageJson = require('../package.json'); const xtermHeadlessPackageJson = { ...xtermPackageJson, @@ -23,17 +22,23 @@ const xtermHeadlessPackageJson = { delete xtermHeadlessPackageJson['scripts']; delete xtermHeadlessPackageJson['devDependencies']; delete xtermHeadlessPackageJson['style']; -xtermHeadlessPackageJson.version += '-alpha'; +xtermHeadlessPackageJson.version += '-alpha1'; fs.writeFileSync(join(headlessRoot, 'package.json'), JSON.stringify(xtermHeadlessPackageJson, null, 1)); console.log(fs.readFileSync(join(headlessRoot, 'package.json')).toString()); -console.log('> Creating headless/typings'); +console.log('> headless/typings/'); mkdirF(join(headlessRoot, 'typings')); fs.copyFileSync( join(repoRoot, 'typings/xterm-headless.d.ts'), join(headlessRoot, 'typings/xterm-headless.d.ts') ); +console.log('> headless/logo-full.png'); +fs.copyFileSync( + join(repoRoot, 'logo-full.png'), + join(headlessRoot, 'logo-full.png') +); + function mkdirF(p) { if (!fs.existsSync(p)) { fs.mkdirSync(p); diff --git a/headless/.gitignore b/headless/.gitignore index 4aba0be59..aa6706ab3 100644 --- a/headless/.gitignore +++ b/headless/.gitignore @@ -1,3 +1,4 @@ lib-headless/ typings/ +logo-full.png package.json diff --git a/headless/README.md b/headless/README.md index de22b47a1..358c97efb 100644 --- a/headless/README.md +++ b/headless/README.md @@ -1,4 +1,4 @@ -# [![xterm.js logo](../logo-full.png)](https://xtermjs.org) +# [![xterm.js logo](logo-full.png)](https://xtermjs.org) ⚠ This package is a work in progress From be164293170735ab635438d87316083b2f1f0fa9 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 11 Aug 2021 06:23:42 -0700 Subject: [PATCH 059/164] Remove unused compile script --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 2d128b08e..71a0f3080 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,6 @@ "package": "webpack", "package-headless": "webpack --config ./webpack.config.headless.js", "postpackage-headless": "node ./bin/package_headless.js", - "compile": "tsc -b ./src/common/public/tsconfig.json", "start": "node demo/start", "start-debug": "node --inspect-brk demo/start", "lint": "eslint -c .eslintrc.json --max-warnings 0 --ext .ts src/ addons/", From 454c2726a5e0532f93dcf2e5e0ebc0e7cad6b129 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 11 Aug 2021 06:30:15 -0700 Subject: [PATCH 060/164] Add npmignore --- headless/.npmignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 headless/.npmignore diff --git a/headless/.npmignore b/headless/.npmignore new file mode 100644 index 000000000..41f2a3a96 --- /dev/null +++ b/headless/.npmignore @@ -0,0 +1,2 @@ +# Include +!typings/*.d.ts From dda4904d9daa4bb403c3b3d1ebb178c23acd02fa Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 11 Aug 2021 06:42:00 -0700 Subject: [PATCH 061/164] Fix xterm-headless lib file --- webpack.config.headless.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webpack.config.headless.js b/webpack.config.headless.js index 2fe759155..d5bb97b78 100644 --- a/webpack.config.headless.js +++ b/webpack.config.headless.js @@ -33,7 +33,7 @@ module.exports = { } }, output: { - filename: 'xterm.js', + filename: 'xterm-headless.js', path: path.resolve('./headless/lib-headless'), library: { type: 'commonjs' From 12980fbe0c020f4087320e69c85b01b7ede919b4 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 11 Aug 2021 11:18:47 -0700 Subject: [PATCH 062/164] start from scratch, some progress --- src/browser/renderer/BaseRenderLayer.ts | 131 +++++++------- src/browser/renderer/BoxAndBlockCharacters.ts | 162 ++++++++++++++++++ src/common/CoreTerminal.ts | 31 ++-- 3 files changed, 250 insertions(+), 74 deletions(-) diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index aefc0369d..0fbd94551 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -17,7 +17,7 @@ import { IBufferService, IOptionsService } from 'common/services/Services'; import { throwIfFalsy } from 'browser/renderer/RendererUtils'; import { channels, color, rgba } from 'browser/Color'; import { removeElementFromParent } from 'browser/Dom'; -import { boxDrawingBoxes, boxDrawingLineSegments } from 'browser/renderer/BoxAndBlockCharacters'; +import { boxDrawingBoxes, boxDrawingLineSegments, draw } from 'browser/renderer/BoxAndBlockCharacters'; export abstract class BaseRenderLayer implements IRenderLayer { private _canvas: HTMLCanvasElement; @@ -412,71 +412,84 @@ export abstract class BaseRenderLayer implements IRenderLayer { if (!lineSegments) { return false; } + const xOffset = x * this._scaledCellWidth + this._scaledCharLeft; + const verticalCenter = Math.round(this._scaledCellHeight / 2); - // TODO: Clean below - const scale = window.devicePixelRatio; + const yOffset = y * this._scaledCellHeight + this._scaledCharTop + verticalCenter; + // const scale = window.devicePixelRatio; this._ctx.strokeStyle = this._ctx.fillStyle; // increase # of pixels when font size incremented by 10 this._ctx.lineWidth = Math.max(Math.floor(this._optionsService.options.fontSize / 10), 1); - - const xOffset = x * this._scaledCellWidth + this._scaledCharLeft; - const yOffset = y * this._scaledCellHeight + this._scaledCharTop; const horizontalCenter = Math.round(this._scaledCellWidth / 2); - const verticalCenter = Math.round(this._scaledCellHeight / 2); - const xPoints = [ - xOffset, - xOffset + horizontalCenter - scale * 2, - xOffset + horizontalCenter - scale, - xOffset + horizontalCenter, - xOffset + horizontalCenter + scale, - xOffset + horizontalCenter + scale * 2, - xOffset + this._scaledCellWidth - ]; - const yPoints = [ - yOffset - 1, - yOffset + verticalCenter - scale * 2, - yOffset + verticalCenter - scale, - yOffset + verticalCenter, - yOffset + verticalCenter + scale, - yOffset + verticalCenter + scale * 2, - yOffset + this._scaledCellHeight - ]; - - for (let i = 0; i < lineSegments.length; i++) { - const line = lineSegments[i]; - - if (i === 0 || (line.x1 !== lineSegments[i - 1].x2 || line.y1 !== lineSegments[i - 1].y2)) { - this._ctx.beginPath(); - if (this._ctx.lineWidth % 2 === 1) { - this._ctx.moveTo(line.x1 === 0 ? xPoints[line.x1] : xPoints[line.x1] + .5, yPoints[line.y1] + .5); - } else { - this._ctx.moveTo(xPoints[line.x1], yPoints[line.y1]); - } - } - - if (typeof line.cx1 !== 'undefined') { - // Draw curve - this._ctx.bezierCurveTo( - xPoints[line.cx1], - yPoints[line.cy1], - xPoints[line.cx2], - yPoints[line.cy2], - xPoints[line.x2], - yPoints[line.y2]); - } else { - // Draw line - if (this._ctx.lineWidth % 2 === 1) { - this._ctx.lineTo(line.x2 === 0 ? xPoints[line.x2] : xPoints[line.x2] + .5, yPoints[line.y2] + .5); - } else { - this._ctx.lineTo(xPoints[line.x2], yPoints[line.y2]); - } - } - - this._ctx.stroke(); - } - + draw(this._ctx, char, xOffset, yOffset - verticalCenter, this._scaledCellWidth, this._scaledCellHeight); return true; + + + // // TODO: Clean below + // const scale = window.devicePixelRatio; + // this._ctx.strokeStyle = this._ctx.fillStyle; + + // // increase # of pixels when font size incremented by 10 + // this._ctx.lineWidth = Math.max(Math.floor(this._optionsService.options.fontSize / 10), 1); + + // const xOffset = x * this._scaledCellWidth + this._scaledCharLeft; + // const yOffset = y * this._scaledCellHeight + this._scaledCharTop; + // const horizontalCenter = Math.round(this._scaledCellWidth / 2); + // const verticalCenter = Math.round(this._scaledCellHeight / 2); + // const xPoints = [ + // xOffset, + // xOffset + horizontalCenter - scale * 2, + // xOffset + horizontalCenter - scale, + // xOffset + horizontalCenter, + // xOffset + horizontalCenter + scale, + // xOffset + horizontalCenter + scale * 2, + // xOffset + this._scaledCellWidth + // ]; + // const yPoints = [ + // yOffset - 1, + // yOffset + verticalCenter - scale * 2, + // yOffset + verticalCenter - scale, + // yOffset + verticalCenter, + // yOffset + verticalCenter + scale, + // yOffset + verticalCenter + scale * 2, + // yOffset + this._scaledCellHeight + // ]; + + // for (let i = 0; i < lineSegments.length; i++) { + // const line = lineSegments[i]; + + // if (i === 0 || (line.x1 !== lineSegments[i - 1].x2 || line.y1 !== lineSegments[i - 1].y2)) { + // this._ctx.beginPath(); + // if (this._ctx.lineWidth % 2 === 1) { + // this._ctx.moveTo(line.x1 === 0 ? xPoints[line.x1] : xPoints[line.x1] + .5, yPoints[line.y1] + .5); + // } else { + // this._ctx.moveTo(xPoints[line.x1], yPoints[line.y1]); + // } + // } + + // if (typeof line.cx1 !== 'undefined') { + // // Draw curve + // this._ctx.bezierCurveTo( + // xPoints[line.cx1], + // yPoints[line.cy1], + // xPoints[line.cx2], + // yPoints[line.cy2], + // xPoints[line.x2], + // yPoints[line.y2]); + // } else { + // // Draw line + // if (this._ctx.lineWidth % 2 === 1) { + // this._ctx.lineTo(line.x2 === 0 ? xPoints[line.x2] : xPoints[line.x2] + .5, yPoints[line.y2] + .5); + // } else { + // this._ctx.lineTo(xPoints[line.x2], yPoints[line.y2]); + // } + // } + + // this._ctx.stroke(); + // } + + // return true; } diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 221a0e4f9..eda537258 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -211,3 +211,165 @@ export const boxDrawingBoxes: { [index: string]: any } = { // HEAVY HORIZONTAL FILL (upper middle and lower one quarter block) '\u{1FB97}': [{ x: 0, y: 2, w: 8, h: 2 }, { x: 0, y: 6, w: 8, h: 2 }] }; + +export const chars: { [index: string]: string } = { + '━': 'M0,.5, L1,.5 z', + '│': 'M0,0, L0,2 z', + '┃': 'M0,0, L0,2 z!', + '┌': 'M , L , z', + '┍': 'M , L , z', + '┎': 'M , L , z', + '┏': 'M , L , z', + '┐': 'M , L , z', + '┑': 'M , L , z', + '┒': 'M , L , z', + '┓': 'M , L , z', + '└': 'M , L , z', + '┕': 'M , L , z', + '┖': 'M , L , z', + '┗': 'M , L , z', + '┘': 'M , L , z', + '┙': 'M , L , z', + '┚': 'M , L , z', + '┛': 'M , L , z', + '├': 'M , L , z', + '┝': 'M , L , z', + '┞': 'M , L , z', + '┟': 'M , L , z', + '┠': 'M , L , z', + '┡': 'M , L , z', + '┢': 'M , L , z', + '┣': 'M , L , z', + '┤': 'M , L , z', + '┥': 'M , L , z', + '┦': 'M , L , z', + '┧': 'M , L , z', + '┨': 'M , L , z', + '┩': 'M , L , z', + '┪': 'M , L , z', + '┫': 'M , L , z', + '┬': 'M , L , z', + '┭': 'M , L , z', + '┮': 'M , L , z', + '┯': 'M , L , z', + '┰': 'M , L , z', + '┱': 'M , L , z', + '┲': 'M , L , z', + '┳': 'M , L , z', + '┴': 'M , L , z', + '┵': 'M , L , z', + '┶': 'M , L , z', + '┷': 'M , L , z', + '┸': 'M , L , z', + '┹': 'M , L , z', + '┺': 'M , L , z', + '┻': 'M , L , z', + '┼': 'M , L , z', + '┽': 'M , L , z', + '┾': 'M , L , z', + '┿': 'M , L , z', + '╀': 'M , L , z', + '╁': 'M , L , z', + '╂': 'M , L , z', + '╃': 'M , L , z', + '╄': 'M , L , z', + '╅': 'M , L , z', + '╆': 'M , L , z', + '╇': 'M , L , z', + '╈': 'M , L , z', + '╉': 'M , L , z', + '╊': 'M , L , z', + '╋': 'M , L , z', + '╌': 'M , L , z', + '╍': 'M , L , z', + '╎': 'M , L , z', + '╏': 'M , L , z', + '═': 'M , L , z', + '║': 'M , L , z', + '╒': 'M , L , z', + '╓': 'M , L , z', + '╔': 'M , L , z', + '╕': 'M , L , z', + '╖': 'M , L , z', + '╗': 'M , L , z', + '╘': 'M , L , z', + '╙': 'M , L , z', + '╚': 'M , L , z', + '╛': 'M , L , z', + '╜': 'M , L , z', + '╝': 'M , L , z', + '╞': 'M , L , z', + '╟': 'M , L , z', + '╠': 'M , L , z', + '╡': 'M , L , z', + '╢': 'M , L , z', + '╣': 'M , L , z', + '╤': 'M , L , z', + '╥': 'M , L , z', + '╦': 'M , L , z', + '╧': 'M , L , z', + '╨': 'M , L , z', + '╩': 'M , L , z', + '╪': 'M , L , z', + '╫': 'M , L , z', + '╬': 'M , L , z', + '╭': 'M , L , z', + '╮': 'M , L , z', + '╯': 'M , L , z', + '╰': 'M , L , z', + '╱': 'M , L , z', + '╲': 'M , L , z', + '╳': 'M , L , z', + '╴': 'M , L , z', + '╵': 'M , L , z', + '╶': 'M , L , z', + '╷': 'M , L , z', + '╸': 'M , L , z', + '╹': 'M , L , z', + '╺': 'M , L , z', + '╻': 'M , L , z', + '╼': 'M , L , z', + '╽': 'M , L , z', + '╾': 'M , L , z', + '╿': 'M0,0, L0,10 z' +}; + +export function draw(ctx: CanvasRenderingContext2D, c: string, xOffset: number, yOffset: number, cellWidth: number, cellHeight: number): void { + const entry = chars[c]; + console.log(c); + if (!entry) { + return; + } + const instructions = entry.split(' '); + for (const instruction of instructions) { + if (instruction.endsWith('!')) { + ctx.lineWidth = ctx.lineWidth * 2; + } + const type = instruction[0]; + const spec = instructionMap[type]; + const coords: string[] = instruction.substring(1).split(','); + if (!coords[0] || !coords[1]) { + continue; + } + + + const numX = Number.parseFloat(coords[0].toString()) || Number.parseInt(coords[0].toString()); + const numY = Number.parseFloat(coords[1].toString()) || Number.parseInt(coords[1].toString()); + spec(ctx, xOffset + Math.round((numX)*cellWidth), yOffset + ((numY))*cellHeight); + } + ctx.stroke(); +} + +const instructionMap: { [index: string]: any } = { + 'M': (ctx: CanvasRenderingContext2D, x: number, y: number) => { + ctx.beginPath(); + ctx.moveTo(x, y); + }, + 'L': (ctx: CanvasRenderingContext2D, x: number, y: number) => { + ctx.lineTo(x, y); + }, + 'z': (ctx: CanvasRenderingContext2D) => { + ctx.closePath(); + console.log('closing path'); + } +}; diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 5758957e1..710f61648 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -133,21 +133,22 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { // Setup WriteBuffer this._writeBuffer = new WriteBuffer((data, promiseResult) => this._inputHandler.parse(data, promiseResult)); setTimeout(() => { - this.write('─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏\r\n'); - this.write('┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟\r\n'); - this.write('┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯\r\n'); - this.write('┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿\r\n'); - this.write('╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╌ ╍ ╎ ╏\r\n'); - this.write('═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟\r\n'); - this.write('╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯\r\n'); - this.write('╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\r\n'); - this.write('▇▇▇▇▇▇▇▇▇'); - this.write(' ╔═════════════════════════════════════════════════════════╕\r\n'); - this.write(' ║ │\r\n'); - this.write(' ║ ╔═══════════════╦════════╤════════╗ │\r\n'); - this.write(' ║ ║ ║ │ ║ │\r\n'); - this.write(' ║ ║ ║ │ ║ │\r\n'); - }, 1500); + // this.write('─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏\r\n'); + // this.write('┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟\r\n'); + // this.write('┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯\r\n'); + // this.write('┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿\r\n'); + // this.write('╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╌ ╍ ╎ ╏\r\n'); + // this.write('═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟\r\n'); + // this.write('╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯\r\n'); + // this.write('╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\r\n'); + // this.write(' ╔═════════════════════════════════════════════════════════╕\r\n'); + // this.write(' ║ │\r\n'); + // this.write(' ║ ╔═══════════════╦════════╤════════╗ │\r\n'); + // this.write(' ║ ║ ║ │ ║ │\r\n'); + // this.write(' ║ ║ ║ │ ║ │\r\n'); + // this.write('▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇'); + this.write('━│┃'); + }, 1000); } public dispose(): void { From db845a6f24c9492199081eb0f569acc0871e4de7 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 11 Aug 2021 14:14:17 -0700 Subject: [PATCH 063/164] make a bunch of progress --- src/browser/renderer/BaseRenderLayer.ts | 3 +- src/browser/renderer/BoxAndBlockCharacters.ts | 282 ++++++++++-------- src/common/CoreTerminal.ts | 4 +- 3 files changed, 156 insertions(+), 133 deletions(-) diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 0fbd94551..39819353e 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -422,7 +422,8 @@ export abstract class BaseRenderLayer implements IRenderLayer { // increase # of pixels when font size incremented by 10 this._ctx.lineWidth = Math.max(Math.floor(this._optionsService.options.fontSize / 10), 1); const horizontalCenter = Math.round(this._scaledCellWidth / 2); - draw(this._ctx, char, xOffset, yOffset - verticalCenter, this._scaledCellWidth, this._scaledCellHeight); + // yOffset - verticalCenter + draw(this._ctx, char, xOffset, y * this._scaledCellHeight + this._scaledCharTop, this._scaledCellWidth, this._scaledCellHeight); return true; diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index eda537258..de8a349ca 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -212,152 +212,173 @@ export const boxDrawingBoxes: { [index: string]: any } = { '\u{1FB97}': [{ x: 0, y: 2, w: 8, h: 2 }, { x: 0, y: 6, w: 8, h: 2 }] }; +export const enum CENTER { + BOTTOM ='.5,1', + TOP = '.5,0', + MIDDLE = '.5,.5' +} + +export const enum LEFT { + BOTTOM = '0,1', + TOP = '0,0', + MIDDLE = '0,.5' +} + +export const enum RIGHT { + BOTTOM = '1,1', + TOP = '1,0', + MIDDLE = '1,.5' +} + +const MOVE = 'M'; +const TO = 'L'; +const BOLD = '!'; + export const chars: { [index: string]: string } = { - '━': 'M0,.5, L1,.5 z', - '│': 'M0,0, L0,2 z', - '┃': 'M0,0, L0,2 z!', - '┌': 'M , L , z', - '┍': 'M , L , z', - '┎': 'M , L , z', - '┏': 'M , L , z', - '┐': 'M , L , z', - '┑': 'M , L , z', - '┒': 'M , L , z', - '┓': 'M , L , z', - '└': 'M , L , z', - '┕': 'M , L , z', - '┖': 'M , L , z', - '┗': 'M , L , z', - '┘': 'M , L , z', - '┙': 'M , L , z', - '┚': 'M , L , z', - '┛': 'M , L , z', - '├': 'M , L , z', - '┝': 'M , L , z', - '┞': 'M , L , z', - '┟': 'M , L , z', - '┠': 'M , L , z', - '┡': 'M , L , z', - '┢': 'M , L , z', - '┣': 'M , L , z', - '┤': 'M , L , z', - '┥': 'M , L , z', - '┦': 'M , L , z', - '┧': 'M , L , z', - '┨': 'M , L , z', - '┩': 'M , L , z', - '┪': 'M , L , z', - '┫': 'M , L , z', - '┬': 'M , L , z', - '┭': 'M , L , z', - '┮': 'M , L , z', - '┯': 'M , L , z', - '┰': 'M , L , z', - '┱': 'M , L , z', - '┲': 'M , L , z', - '┳': 'M , L , z', - '┴': 'M , L , z', - '┵': 'M , L , z', - '┶': 'M , L , z', - '┷': 'M , L , z', - '┸': 'M , L , z', - '┹': 'M , L , z', - '┺': 'M , L , z', - '┻': 'M , L , z', - '┼': 'M , L , z', - '┽': 'M , L , z', - '┾': 'M , L , z', - '┿': 'M , L , z', - '╀': 'M , L , z', - '╁': 'M , L , z', - '╂': 'M , L , z', - '╃': 'M , L , z', - '╄': 'M , L , z', - '╅': 'M , L , z', - '╆': 'M , L , z', - '╇': 'M , L , z', - '╈': 'M , L , z', - '╉': 'M , L , z', - '╊': 'M , L , z', - '╋': 'M , L , z', - '╌': 'M , L , z', - '╍': 'M , L , z', - '╎': 'M , L , z', - '╏': 'M , L , z', - '═': 'M , L , z', - '║': 'M , L , z', - '╒': 'M , L , z', - '╓': 'M , L , z', - '╔': 'M , L , z', - '╕': 'M , L , z', - '╖': 'M , L , z', - '╗': 'M , L , z', - '╘': 'M , L , z', - '╙': 'M , L , z', - '╚': 'M , L , z', - '╛': 'M , L , z', - '╜': 'M , L , z', - '╝': 'M , L , z', - '╞': 'M , L , z', - '╟': 'M , L , z', - '╠': 'M , L , z', - '╡': 'M , L , z', - '╢': 'M , L , z', - '╣': 'M , L , z', - '╤': 'M , L , z', - '╥': 'M , L , z', - '╦': 'M , L , z', - '╧': 'M , L , z', - '╨': 'M , L , z', - '╩': 'M , L , z', - '╪': 'M , L , z', - '╫': 'M , L , z', - '╬': 'M , L , z', - '╭': 'M , L , z', - '╮': 'M , L , z', - '╯': 'M , L , z', - '╰': 'M , L , z', - '╱': 'M , L , z', - '╲': 'M , L , z', - '╳': 'M , L , z', - '╴': 'M , L , z', - '╵': 'M , L , z', - '╶': 'M , L , z', - '╷': 'M , L , z', - '╸': 'M , L , z', - '╹': 'M , L , z', - '╺': 'M , L , z', - '╻': 'M , L , z', - '╼': 'M , L , z', - '╽': 'M , L , z', - '╾': 'M , L , z', - '╿': 'M0,0, L0,10 z' + '━': `${MOVE}${LEFT.MIDDLE} ${TO}${RIGHT.MIDDLE}`, + '│': `${MOVE}${CENTER.TOP} ${TO}${CENTER.BOTTOM}`, + '┃': `${MOVE}${CENTER.TOP} ${TO}${CENTER.BOTTOM}${BOLD}`, + '┌': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE} ${TO}${RIGHT.MIDDLE}`, + '┍': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE} ${TO}${RIGHT.MIDDLE}${BOLD}`, + '┎': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE}${BOLD} ${TO}${RIGHT.MIDDLE}`, + '┏': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE}${BOLD} ${TO}${RIGHT.MIDDLE}${BOLD}`, + '┐': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE} ${TO}${LEFT.MIDDLE}`, + '┑': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE} ${TO}${LEFT.MIDDLE}${BOLD}`, + '┒': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE}${BOLD} ${TO}${LEFT.MIDDLE}`, + '┓': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE}${BOLD} ${TO}${LEFT.MIDDLE}${BOLD}` + // '└': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┕': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┖': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┗': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┘': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┙': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┚': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┛': `${MOVE}${} ${TO}${} ${TO}${}`, + // '├': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┝': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┞': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┟': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┠': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┡': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┢': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┣': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┤': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┥': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┦': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┧': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┨': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┩': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┪': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┫': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┬': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┭': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┮': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┯': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┰': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┱': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┲': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┳': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┴': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┵': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┶': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┷': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┸': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┹': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┺': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┻': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┼': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┽': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┾': `${MOVE}${} ${TO}${} ${TO}${}`, + // '┿': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╀': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╁': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╂': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╃': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╄': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╅': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╆': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╇': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╈': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╉': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╊': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╋': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╌': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╍': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╎': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╏': `${MOVE}${} ${TO}${} ${TO}${}`, + // '═': `${MOVE}${} ${TO}${} ${TO}${}`, + // '║': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╒': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╓': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╔': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╕': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╖': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╗': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╘': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╙': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╚': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╛': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╜': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╝': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╞': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╟': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╠': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╡': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╢': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╣': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╤': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╥': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╦': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╧': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╨': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╩': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╪': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╫': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╬': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╭': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╮': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╯': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╰': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╱': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╲': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╳': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╴': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╵': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╶': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╷': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╸': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╹': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╺': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╻': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╼': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╽': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╾': `${MOVE}${} ${TO}${} ${TO}${}`, + // '╿': `${MOVE}${} ${TO}${} ${TO}${}` }; export function draw(ctx: CanvasRenderingContext2D, c: string, xOffset: number, yOffset: number, cellWidth: number, cellHeight: number): void { const entry = chars[c]; - console.log(c); if (!entry) { return; } + const lineWidth = ctx.lineWidth; const instructions = entry.split(' '); for (const instruction of instructions) { - if (instruction.endsWith('!')) { - ctx.lineWidth = ctx.lineWidth * 2; - } const type = instruction[0]; const spec = instructionMap[type]; const coords: string[] = instruction.substring(1).split(','); if (!coords[0] || !coords[1]) { continue; } - - const numX = Number.parseFloat(coords[0].toString()) || Number.parseInt(coords[0].toString()); const numY = Number.parseFloat(coords[1].toString()) || Number.parseInt(coords[1].toString()); - spec(ctx, xOffset + Math.round((numX)*cellWidth), yOffset + ((numY))*cellHeight); + if (instruction.endsWith(BOLD)) { + ctx.lineWidth = lineWidth * 2; + } else { + ctx.lineWidth = lineWidth; + } + spec(ctx, xOffset + Math.round((numX) * cellWidth), yOffset + ((numY)) * cellHeight); } - ctx.stroke(); } const instructionMap: { [index: string]: any } = { @@ -367,9 +388,8 @@ const instructionMap: { [index: string]: any } = { }, 'L': (ctx: CanvasRenderingContext2D, x: number, y: number) => { ctx.lineTo(x, y); - }, - 'z': (ctx: CanvasRenderingContext2D) => { - ctx.closePath(); - console.log('closing path'); + ctx.stroke(); + ctx.beginPath(); + ctx.moveTo(x, y); } }; diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 710f61648..32341d8d8 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -147,7 +147,9 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { // this.write(' ║ ║ ║ │ ║ │\r\n'); // this.write(' ║ ║ ║ │ ║ │\r\n'); // this.write('▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇'); - this.write('━│┃'); + this.write('━━│┃\r\n'); + this.write(' ━━│┃┌┍┎┏\r\n'); + this.write(' ━━│┃┌┐┍┑┎┒┏┓'); }, 1000); } From 57c7e6af4703cd4040da36baa36bd3f47a166e14 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 11 Aug 2021 15:19:12 -0700 Subject: [PATCH 064/164] add more characters --- src/browser/renderer/BoxAndBlockCharacters.ts | 147 ++++++++++-------- src/common/CoreTerminal.ts | 7 +- 2 files changed, 84 insertions(+), 70 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index de8a349ca..b57a9c568 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -232,76 +232,85 @@ export const enum RIGHT { const MOVE = 'M'; const TO = 'L'; -const BOLD = '!'; +const THICK = '!'; + +const yAxis = `${MOVE}${CENTER.TOP} ${TO}${CENTER.BOTTOM}`; +const xAxis = `${MOVE}${LEFT.MIDDLE} ${TO}${RIGHT.MIDDLE}`; +const bottomYAxisFromBottom = `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE}`; +const bottomYAxisFromMiddle = `${MOVE}${CENTER.MIDDLE} ${TO}${CENTER.BOTTOM}`; +const topYAxisFromTop = `${MOVE}${CENTER.TOP} ${TO}${CENTER.MIDDLE}`; +const topYAxisFromMiddle = `${MOVE}${CENTER.TOP} ${TO}${CENTER.MIDDLE}`; +const rightMiddleXAxis = `${MOVE}${CENTER.MIDDLE} ${TO}${RIGHT.MIDDLE}`; +const leftMiddleXAxis = `${MOVE}${CENTER.MIDDLE} ${TO}${LEFT.MIDDLE}`; export const chars: { [index: string]: string } = { - '━': `${MOVE}${LEFT.MIDDLE} ${TO}${RIGHT.MIDDLE}`, - '│': `${MOVE}${CENTER.TOP} ${TO}${CENTER.BOTTOM}`, - '┃': `${MOVE}${CENTER.TOP} ${TO}${CENTER.BOTTOM}${BOLD}`, - '┌': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE} ${TO}${RIGHT.MIDDLE}`, - '┍': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE} ${TO}${RIGHT.MIDDLE}${BOLD}`, - '┎': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE}${BOLD} ${TO}${RIGHT.MIDDLE}`, - '┏': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE}${BOLD} ${TO}${RIGHT.MIDDLE}${BOLD}`, - '┐': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE} ${TO}${LEFT.MIDDLE}`, - '┑': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE} ${TO}${LEFT.MIDDLE}${BOLD}`, - '┒': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE}${BOLD} ${TO}${LEFT.MIDDLE}`, - '┓': `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE}${BOLD} ${TO}${LEFT.MIDDLE}${BOLD}` - // '└': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┕': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┖': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┗': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┘': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┙': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┚': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┛': `${MOVE}${} ${TO}${} ${TO}${}`, - // '├': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┝': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┞': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┟': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┠': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┡': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┢': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┣': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┤': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┥': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┦': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┧': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┨': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┩': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┪': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┫': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┬': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┭': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┮': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┯': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┰': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┱': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┲': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┳': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┴': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┵': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┶': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┷': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┸': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┹': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┺': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┻': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┼': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┽': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┾': `${MOVE}${} ${TO}${} ${TO}${}`, - // '┿': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╀': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╁': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╂': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╃': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╄': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╅': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╆': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╇': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╈': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╉': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╊': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╋': `${MOVE}${} ${TO}${} ${TO}${}`, + '━': `${xAxis}`, + '│': `${yAxis}`, + '┃': `${yAxis}${THICK}`, + '┌': `${bottomYAxisFromBottom} ${TO}${RIGHT.MIDDLE}`, + '┍': `${bottomYAxisFromBottom} ${TO}${RIGHT.MIDDLE}${THICK}`, + '┎': `${bottomYAxisFromBottom}${THICK} ${TO}${RIGHT.MIDDLE}`, + '┏': `${bottomYAxisFromBottom}${THICK} ${TO}${RIGHT.MIDDLE}${THICK}`, + '┐': `${bottomYAxisFromBottom} ${TO}${LEFT.MIDDLE}`, + '┑': `${bottomYAxisFromBottom} ${TO}${LEFT.MIDDLE}${THICK}`, + '┒': `${bottomYAxisFromBottom}${THICK} ${TO}${LEFT.MIDDLE}`, + '┓': `${bottomYAxisFromBottom}${THICK} ${TO}${LEFT.MIDDLE}${THICK}`, + '└': `${topYAxisFromTop} ${TO}${RIGHT.MIDDLE}`, + '┕': `${topYAxisFromTop} ${TO}${RIGHT.MIDDLE}${THICK}`, + '┖': `${topYAxisFromTop}${THICK} ${TO}${RIGHT.MIDDLE}`, + '┗': `${topYAxisFromTop}${THICK} ${TO}${RIGHT.MIDDLE}${THICK}`, + '┘': `${topYAxisFromTop} ${TO}${LEFT.MIDDLE}`, + '┙': `${topYAxisFromTop} ${TO}${LEFT.MIDDLE}${THICK}`, + '┚': `${topYAxisFromTop}${THICK} ${TO}${LEFT.MIDDLE}`, + '┛': `${topYAxisFromTop}${THICK} ${TO}${LEFT.MIDDLE}${THICK}`, + '├': `${yAxis} ${rightMiddleXAxis}`, + '┝': `${yAxis} ${rightMiddleXAxis}${THICK}`, + '┞': `${topYAxisFromTop}${THICK} ${bottomYAxisFromMiddle} ${rightMiddleXAxis}`, + '┟': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${rightMiddleXAxis}${THICK}`, + '┠': `${yAxis}${THICK} ${rightMiddleXAxis}`, + '┡': `${bottomYAxisFromBottom} ${topYAxisFromMiddle}${THICK} ${rightMiddleXAxis}${THICK}`, + '┢': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${rightMiddleXAxis}${THICK}`, + '┣': `${yAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + '┤': `${yAxis} ${leftMiddleXAxis}`, + '┥': `${yAxis} ${leftMiddleXAxis}${THICK}`, + '┦': `${topYAxisFromTop}${THICK} ${bottomYAxisFromMiddle} ${leftMiddleXAxis}`, + '┧': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${leftMiddleXAxis}${THICK}`, + '┨': `${yAxis}${THICK} ${leftMiddleXAxis}`, + '┩': `${bottomYAxisFromBottom} ${topYAxisFromMiddle}${THICK} ${leftMiddleXAxis}${THICK}`, + '┪': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${leftMiddleXAxis}${THICK}`, + '┫': `${yAxis}${THICK} ${leftMiddleXAxis}${THICK}`, + '┬': `${bottomYAxisFromBottom} ${xAxis}`, + '┭': `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + '┮': `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + '┯': `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + '┰': `${bottomYAxisFromBottom}${THICK} ${xAxis}`, + '┱': `${bottomYAxisFromBottom}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + '┲': `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + '┳': `${bottomYAxisFromBottom}${THICK} ${xAxis}${THICK}`, + '┴': `${topYAxisFromTop} ${xAxis}`, + '┵': `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + '┶': `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + '┷': `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + '┸': `${topYAxisFromTop}${THICK} ${xAxis}`, + '┹': `${topYAxisFromTop}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + '┺': `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + '┻': `${topYAxisFromTop}${THICK} ${xAxis}${THICK}`, + '┼': `${yAxis} ${xAxis}`, + '┽': `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + '┾': `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + '┿': `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + '╀': `${yAxis}${THICK} ${xAxis}`, + '╁': `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + '╂': `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + '╃': `${yAxis}${THICK} ${xAxis}${THICK}`, + '╄': `${yAxis} ${xAxis}`, + '╅': `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + '╆': `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + '╇': `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + '╈': `${yAxis}${THICK} ${xAxis}`, + '╉': `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + '╊': `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + '╋': `${yAxis}${THICK} ${xAxis}${THICK}` // '╌': `${MOVE}${} ${TO}${} ${TO}${}`, // '╍': `${MOVE}${} ${TO}${} ${TO}${}`, // '╎': `${MOVE}${} ${TO}${} ${TO}${}`, @@ -372,7 +381,7 @@ export function draw(ctx: CanvasRenderingContext2D, c: string, xOffset: number, } const numX = Number.parseFloat(coords[0].toString()) || Number.parseInt(coords[0].toString()); const numY = Number.parseFloat(coords[1].toString()) || Number.parseInt(coords[1].toString()); - if (instruction.endsWith(BOLD)) { + if (instruction.endsWith(THICK)) { ctx.lineWidth = lineWidth * 2; } else { ctx.lineWidth = lineWidth; diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 32341d8d8..7c3f0e03f 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -149,7 +149,12 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { // this.write('▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇'); this.write('━━│┃\r\n'); this.write(' ━━│┃┌┍┎┏\r\n'); - this.write(' ━━│┃┌┐┍┑┎┒┏┓'); + this.write(' ━━│┃┌┐┍┑┎┒┏┓\r\n'); + this.write(' └┘┕┙┖┚┗┛\r\n'); + this.write('├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿╀╁╂╃╄╅╆╇╈╉╊╋╌╍╎╏═║╒╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡╢╣╤╥╦╧╨╩╪╫╬╭╮╯╰╱╲╳╴╵╶╷╸╹╺╻╼╽╾╿\r\n'); + this.write('├ ┝ ┞ ┟ ┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯ ┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻\r\n'); + this.write('┼ ┽ ┾ ┿ ╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋\r\n'); + this.write('╌ ╍ ╎ ╏ ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯ ╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\r\n'); }, 1000); } From 927a1424809d2cbbb4888923cbcf0fd9b32eca5a Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 11 Aug 2021 15:36:29 -0700 Subject: [PATCH 065/164] add more --- src/browser/renderer/BoxAndBlockCharacters.ts | 34 +++++++++---------- src/common/CoreTerminal.ts | 6 ++-- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index b57a9c568..bbba50903 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -310,11 +310,11 @@ export const chars: { [index: string]: string } = { '╈': `${yAxis}${THICK} ${xAxis}`, '╉': `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, '╊': `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - '╋': `${yAxis}${THICK} ${xAxis}${THICK}` - // '╌': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╍': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╎': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╏': `${MOVE}${} ${TO}${} ${TO}${}`, + '╋': `${yAxis}${THICK} ${xAxis}${THICK}`, + '╌': `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}`, + '╍': `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'}${THICK} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}${THICK}`, + '╎':`${MOVE}${CENTER.BOTTOM} ${TO}${'.5,.3'} ${MOVE}${'.5,.7'} ${TO}${CENTER.TOP}`, + '╏':`${MOVE}${CENTER.BOTTOM} ${TO}${'.5,.3'}${THICK} ${MOVE}${'.5,.7'} ${TO}${CENTER.TOP}${THICK}`, // '═': `${MOVE}${} ${TO}${} ${TO}${}`, // '║': `${MOVE}${} ${TO}${} ${TO}${}`, // '╒': `${MOVE}${} ${TO}${} ${TO}${}`, @@ -351,18 +351,18 @@ export const chars: { [index: string]: string } = { // '╱': `${MOVE}${} ${TO}${} ${TO}${}`, // '╲': `${MOVE}${} ${TO}${} ${TO}${}`, // '╳': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╴': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╵': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╶': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╷': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╸': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╹': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╺': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╻': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╼': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╽': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╾': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╿': `${MOVE}${} ${TO}${} ${TO}${}` + '╴': `${leftMiddleXAxis}`, + '╵': `${topYAxisFromMiddle}`, + '╶': `${rightMiddleXAxis}`, + '╷': `${bottomYAxisFromMiddle}`, + '╸': `${leftMiddleXAxis}${THICK}`, + '╹': `${topYAxisFromMiddle}${THICK}`, + '╺': `${rightMiddleXAxis}${THICK}`, + '╻': `${bottomYAxisFromMiddle}${THICK}`, + '╼': `${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + '╽': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle}`, + '╾': `${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + '╿': `${bottomYAxisFromBottom} ${topYAxisFromMiddle}${THICK}` }; export function draw(ctx: CanvasRenderingContext2D, c: string, xOffset: number, yOffset: number, cellWidth: number, cellHeight: number): void { diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index 7c3f0e03f..a3026016a 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -151,10 +151,12 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { this.write(' ━━│┃┌┍┎┏\r\n'); this.write(' ━━│┃┌┐┍┑┎┒┏┓\r\n'); this.write(' └┘┕┙┖┚┗┛\r\n'); - this.write('├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿╀╁╂╃╄╅╆╇╈╉╊╋╌╍╎╏═║╒╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡╢╣╤╥╦╧╨╩╪╫╬╭╮╯╰╱╲╳╴╵╶╷╸╹╺╻╼╽╾╿\r\n'); + this.write('├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿╀╁╂╃╄╅╆╇╈╉╊╋ ╌ ╍╎╏═║╒╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡╢╣╤╥╦╧╨╩╪╫╬\r\n'); + this.write('╭╮╯╰╱╲╳╴╵╶╷╸╹╺╻╼╽╾╿\r\n'); this.write('├ ┝ ┞ ┟ ┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯ ┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻\r\n'); this.write('┼ ┽ ┾ ┿ ╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋\r\n'); - this.write('╌ ╍ ╎ ╏ ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯ ╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\r\n'); + this.write(' ╌ ╍ ╎ ╏ ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬\r\n'); + this.write('╭ ╮ ╯ ╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\r\n'); }, 1000); } From 46cb37876deea04f11401aad6a365f06a3a0b555 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 11 Aug 2021 15:46:50 -0700 Subject: [PATCH 066/164] more working --- src/browser/renderer/BoxAndBlockCharacters.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index bbba50903..379bc2d78 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -311,10 +311,10 @@ export const chars: { [index: string]: string } = { '╉': `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, '╊': `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, '╋': `${yAxis}${THICK} ${xAxis}${THICK}`, - '╌': `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}`, - '╍': `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'}${THICK} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}${THICK}`, - '╎':`${MOVE}${CENTER.BOTTOM} ${TO}${'.5,.3'} ${MOVE}${'.5,.7'} ${TO}${CENTER.TOP}`, - '╏':`${MOVE}${CENTER.BOTTOM} ${TO}${'.5,.3'}${THICK} ${MOVE}${'.5,.7'} ${TO}${CENTER.TOP}${THICK}`, + '╌': `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}`, + '╍': `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'}${THICK} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}${THICK}`, + '╎':`${MOVE}${CENTER.TOP} ${TO}${'.5,.47'} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}`, + '╏':`${MOVE}${CENTER.TOP} ${TO}${'.5,.47'}${THICK} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}${THICK}`, // '═': `${MOVE}${} ${TO}${} ${TO}${}`, // '║': `${MOVE}${} ${TO}${} ${TO}${}`, // '╒': `${MOVE}${} ${TO}${} ${TO}${}`, From 34d6449d076d740a6e2e7fcebe311feb2624042a Mon Sep 17 00:00:00 2001 From: Chad Smith Date: Wed, 11 Aug 2021 23:40:25 -0700 Subject: [PATCH 067/164] add TermPair and gdbgui to real world uses list --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9d926afeb..479c81133 100644 --- a/README.md +++ b/README.md @@ -162,21 +162,23 @@ Xterm.js is used in several world-class applications to provide great terminal e - [**CoCalc**](https://cocalc.com/): Lots of free software pre-installed, to chat, collaborate, develop, program, publish, research, share, teach, in C++, HTML, Julia, Jupyter, LaTeX, Markdown, Python, R, SageMath, Scala, ... - [**Dank Domain**](https://www.DDgame.us/): Open source multiuser medieval game supporting old & new terminal emulation. - [**DockerStacks**](https://docker-stacks.com/): Local LAMP/LEMP development studio -- [**Codecademy**](https://codecademy.com/): Uses xterm.js in its courses on Bash. +- [**Codecademy**](https://codecademy.com/): Uses xterm.js in its courses on Bash. - [**Laravel Ssh Web Client**](https://github.com/roke22/Laravel-ssh-client): Laravel server inventory with ssh web client to connect at server using xterm.js - [**Repl.it**](https://repl.it): Collaborative browser based IDE with support for 50+ different languages. - [**TeleType**](https://github.com/akshaykmr/TeleType): cli tool that allows you to share your terminal online conveniently. Show off mad cli-fu, help a colleague, teach, or troubleshoot. - [**Intervue**](https://www.intervue.io): Pair programming for interviews. Multiple programming languages are supported, with results displayed by xterm.js. -- [**TRASA**](https://trasa.io): Zero trust access to Web, SSH, RDP, and Database services. +- [**TRASA**](https://trasa.io): Zero trust access to Web, SSH, RDP, and Database services. - [**Commas**](https://github.com/CyanSalt/commas): Commas is a hackable terminal and command runner. -- [**Devtron**](https://github.com/devtron-labs/devtron): Software Delivery Workflow For Kubernetes. +- [**Devtron**](https://github.com/devtron-labs/devtron): Software Delivery Workflow For Kubernetes. - [**NxShell**](https://github.com/nxshell/nxshell): An easy to use new terminal for SSH. - [**gifcast**](https://dstein64.github.io/gifcast/): Converts an asciinema cast to an animated GIF. - [**WizardWebssh**](https://gitlab.com/mikeramsey/wizardwebssh): A terminal with Pyqt5 Widget for embedding, which can be used as an ssh client to connect to your ssh servers. It is written in Python, based on tornado, paramiko, and xterm.js. -- [**Wizard Assistant**](https://wizardassistant.com/): Wizard Assistant comes with advanced automation tools, preloaded common and special time-saving commands, and a built-in SSH terminal. Now you can remotely administer, troubleshoot, and analyze any system with ease. +- [**Wizard Assistant**](https://wizardassistant.com/): Wizard Assistant comes with advanced automation tools, preloaded common and special time-saving commands, and a built-in SSH terminal. Now you can remotely administer, troubleshoot, and analyze any system with ease. - [**ucli**](https://github.com/tsadarsh/ucli): Command Line for everyone :family_man_woman_girl_boy: at [www.ucli.tech](https://www.ucli.tech). - [**Tess**](https://github.com/SquitchYT/Tess/): Simple Terminal Fully Customizable for Everyone. - [**HashiCorp Nomad**](https://www.nomadproject.io/): A container orchestrator with the ability to connect to remote tasks via a web interface using websockets and xterm.js. +- [**TermPair**](https://github.com/cs01/termpair): View and control terminals from your browser with end-to-end encryption +- [**gdbgui**](https://github.com/cs01/gdbgui): Browser-based frontend to gdb (gnu debugger) - [And much more...](https://github.com/xtermjs/xterm.js/network/dependents) Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it on our list. Note: Please add any new contributions to the end of the list only. From 7e7dcd991752be5c5e765e6878c607bc162844fe Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 12 Aug 2021 04:51:21 -0700 Subject: [PATCH 068/164] Move node-test into headless folder --- bin/package_headless.js | 2 +- headless/.gitignore | 2 +- headless/.npmignore | 3 +++ headless/package.json | 9 +++++++++ headless/test/README.md | 9 +++++++++ {node-test => headless/test}/index.js | 0 {node-test => headless/test}/package.json | 0 node-test/README.md | 10 ---------- 8 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 headless/package.json create mode 100644 headless/test/README.md rename {node-test => headless/test}/index.js (100%) rename {node-test => headless/test}/package.json (100%) delete mode 100644 node-test/README.md diff --git a/bin/package_headless.js b/bin/package_headless.js index 0d4170df8..0dcec90b6 100644 --- a/bin/package_headless.js +++ b/bin/package_headless.js @@ -22,7 +22,7 @@ const xtermHeadlessPackageJson = { delete xtermHeadlessPackageJson['scripts']; delete xtermHeadlessPackageJson['devDependencies']; delete xtermHeadlessPackageJson['style']; -xtermHeadlessPackageJson.version += '-alpha1'; +xtermHeadlessPackageJson.version += '-alpha3'; fs.writeFileSync(join(headlessRoot, 'package.json'), JSON.stringify(xtermHeadlessPackageJson, null, 1)); console.log(fs.readFileSync(join(headlessRoot, 'package.json')).toString()); diff --git a/headless/.gitignore b/headless/.gitignore index aa6706ab3..f1cf6c8d8 100644 --- a/headless/.gitignore +++ b/headless/.gitignore @@ -1,4 +1,4 @@ lib-headless/ typings/ logo-full.png -package.json +./package.json diff --git a/headless/.npmignore b/headless/.npmignore index 41f2a3a96..c6b33260f 100644 --- a/headless/.npmignore +++ b/headless/.npmignore @@ -1,2 +1,5 @@ # Include !typings/*.d.ts + +# Exclude +test/ diff --git a/headless/package.json b/headless/package.json new file mode 100644 index 000000000..d53761e7a --- /dev/null +++ b/headless/package.json @@ -0,0 +1,9 @@ +{ + "name": "xterm-headless", + "description": "A headless terminal component that runs in Node.js", + "version": "4.13.0-alpha3", + "main": "lib-headless/xterm-headless.js", + "types": "typings/xterm-headless.d.ts", + "repository": "https://github.com/xtermjs/xterm.js", + "license": "MIT" +} \ No newline at end of file diff --git a/headless/test/README.md b/headless/test/README.md new file mode 100644 index 000000000..e48da411e --- /dev/null +++ b/headless/test/README.md @@ -0,0 +1,9 @@ +This is a basic manual test for 'xterm-headless': + +```sh +# From repo root +yarn build +yarn package-headless +cd headless/test +node index.js +``` diff --git a/node-test/index.js b/headless/test/index.js similarity index 100% rename from node-test/index.js rename to headless/test/index.js diff --git a/node-test/package.json b/headless/test/package.json similarity index 100% rename from node-test/package.json rename to headless/test/package.json diff --git a/node-test/README.md b/node-test/README.md deleted file mode 100644 index cd3468488..000000000 --- a/node-test/README.md +++ /dev/null @@ -1,10 +0,0 @@ -Cursory test that 'xterm-headless' works: - -``` -# From root of this repo -npm run compile # Outputs to out/headless -npx webpack --config webpack.config.headless.js # Outputs to lib -cd node-test -npm link ../lib/ -node index.js -``` From ec80fc9421e910bc97fc99fea4ba51ea00f7bdcf Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 12 Aug 2021 04:51:49 -0700 Subject: [PATCH 069/164] Remove alpha from package.json version --- bin/package_headless.js | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/package_headless.js b/bin/package_headless.js index 0dcec90b6..d002a95ec 100644 --- a/bin/package_headless.js +++ b/bin/package_headless.js @@ -22,7 +22,6 @@ const xtermHeadlessPackageJson = { delete xtermHeadlessPackageJson['scripts']; delete xtermHeadlessPackageJson['devDependencies']; delete xtermHeadlessPackageJson['style']; -xtermHeadlessPackageJson.version += '-alpha3'; fs.writeFileSync(join(headlessRoot, 'package.json'), JSON.stringify(xtermHeadlessPackageJson, null, 1)); console.log(fs.readFileSync(join(headlessRoot, 'package.json')).toString()); From e96b472edea9305ea306b6bddb6ef584fe481fa9 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 12 Aug 2021 05:35:20 -0700 Subject: [PATCH 070/164] Start on headless unit tests --- src/headless/Terminal.test.ts | 27 -- src/headless/public/Terminal.test.ts | 547 +++++++++++++++++++++++++++ test/api/Terminal.api.ts | 18 +- 3 files changed, 553 insertions(+), 39 deletions(-) delete mode 100644 src/headless/Terminal.test.ts create mode 100644 src/headless/public/Terminal.test.ts diff --git a/src/headless/Terminal.test.ts b/src/headless/Terminal.test.ts deleted file mode 100644 index 07f904361..000000000 --- a/src/headless/Terminal.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2016 The xterm.js authors. All rights reserved. - * @license MIT - */ - -import { deepStrictEqual, throws } from 'assert'; -import { Terminal } from 'headless/public/Terminal'; - -const INIT_COLS = 80; -const INIT_ROWS = 24; - -describe('Headless Terminal', () => { - let term: Terminal; - const termOptions = { - cols: INIT_COLS, - rows: INIT_ROWS - }; - - beforeEach(() => { - term = new Terminal(termOptions); - }); - - it('should throw when trying to change cols or rows', () => { - throws(() => term.setOption('cols', 1000)); - throws(() => term.setOption('rows', 1000)); - }); -}); diff --git a/src/headless/public/Terminal.test.ts b/src/headless/public/Terminal.test.ts new file mode 100644 index 000000000..9f45b78ed --- /dev/null +++ b/src/headless/public/Terminal.test.ts @@ -0,0 +1,547 @@ +/** + * Copyright (c) 2019 The xterm.js authors. All rights reserved. + * @license MIT + */ + +import { strictEqual, throws } from 'assert'; +import { Terminal } from 'headless/public/Terminal'; + +let term: Terminal; + +describe.only('Headless API Tests', function(): void { + beforeEach(() => { + // Create default terminal to be used by most tests + term = new Terminal(); + }); + + it('Default options', async () => { + strictEqual(term.cols, 80); + strictEqual(term.rows, 24); + }); + + it('Proposed API check', async () => { + term = new Terminal({ allowProposedApi: false }); + throws(() => term.buffer, (error) => error.message === 'You must set the allowProposedApi option to true to use proposed API'); + }); + + it('write', async () => { + await writeSync('foo'); + await writeSync('bar'); + await writeSync('文'); + lineEquals(0, 'foobar文'); + }); + + it('write with callback', async () => { + let result: string | undefined; + await new Promise(r => { + term.write('foo', () => { result = 'a'; }); + term.write('bar', () => { result += 'b'; }); + term.write('文', () => { + result += 'c'; + r(); + }); + }); + lineEquals(0, 'foobar文'); + strictEqual(result, 'abc'); + }); + + it('write - bytes (UTF8)', async () => { + await writeSync(new Uint8Array([102, 111, 111])); // foo + await writeSync(new Uint8Array([98, 97, 114])); // bar + await writeSync(new Uint8Array([230, 150, 135])); // 文 + lineEquals(0, 'foobar文'); + }); + + it('write - bytes (UTF8) with callback', async () => { + let result: string | undefined; + await new Promise(r => { + term.write(new Uint8Array([102, 111, 111]), () => { result = 'A'; }); // foo + term.write(new Uint8Array([98, 97, 114]), () => { result += 'B'; }); // bar + term.write(new Uint8Array([230, 150, 135]), () => { // 文 + result += 'C'; + r(); + }); + }); + lineEquals(0, 'foobar文'); + strictEqual(result, 'ABC'); + }); + + it('writeln', async () => { + await writelnSync('foo'); + await writelnSync('bar'); + await writelnSync('文'); + lineEquals(0, 'foo'); + lineEquals(1, 'bar'); + lineEquals(2, '文'); + }); + + it('writeln with callback', async () => { + let result: string | undefined; + await new Promise(r => { + term.writeln('foo', () => { result = '1'; }); + term.writeln('bar', () => { result += '2'; }); + term.writeln('文', () => { + result += '3'; + r(); + }); + }); + lineEquals(0, 'foo'); + lineEquals(1, 'bar'); + lineEquals(2, '文'); + strictEqual(result, '123'); + }); + + it('writeln - bytes (UTF8)', async () => { + await writelnSync(new Uint8Array([102, 111, 111])); + await writelnSync(new Uint8Array([98, 97, 114])); + await writelnSync(new Uint8Array([230, 150, 135])); + lineEquals(0, 'foo'); + lineEquals(1, 'bar'); + lineEquals(2, '文'); + }); + + it('clear', async () => { + term = new Terminal({ rows: 5 }); + for (let i = 0; i < 10; i++) { + await writeSync('\n\rtest' + i); + } + term.clear(); + strictEqual(term.buffer.active.length, 5); + lineEquals(0, 'test9'); + for (let i = 1; i < 5; i++) { + lineEquals(i, ''); + } + }); + + // it('getOption, setOption', async () => { + // await openTerminal(page); + // assert.equal(await page.evaluate(`window.term.getOption('rendererType')`), 'canvas'); + // await page.evaluate(`window.term.setOption('rendererType', 'dom')`); + // assert.equal(await page.evaluate(`window.term.getOption('rendererType')`), 'dom'); + // }); + + // describe('renderer', () => { + // it('foreground', async () => { + // await openTerminal(page, { rendererType: 'dom' }); + // await writeSync(page, '\\x1b[30m0\\x1b[31m1\\x1b[32m2\\x1b[33m3\\x1b[34m4\\x1b[35m5\\x1b[36m6\\x1b[37m7'); + // await pollFor(page, `document.querySelectorAll('.xterm-rows > :nth-child(1) > *').length`, 9); + // assert.deepEqual(await page.evaluate(` + // [ + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(1)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(2)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(3)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(4)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(5)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(6)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(7)').className + // ] + // `), [ + // 'xterm-fg-0', + // 'xterm-fg-1', + // 'xterm-fg-2', + // 'xterm-fg-3', + // 'xterm-fg-4', + // 'xterm-fg-5', + // 'xterm-fg-6' + // ]); + // }); + + // it('background', async () => { + // await openTerminal(page, { rendererType: 'dom' }); + // await writeSync(page, '\\x1b[40m0\\x1b[41m1\\x1b[42m2\\x1b[43m3\\x1b[44m4\\x1b[45m5\\x1b[46m6\\x1b[47m7'); + // await pollFor(page, `document.querySelectorAll('.xterm-rows > :nth-child(1) > *').length`, 9); + // assert.deepEqual(await page.evaluate(` + // [ + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(1)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(2)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(3)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(4)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(5)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(6)').className, + // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(7)').className + // ] + // `), [ + // 'xterm-bg-0', + // 'xterm-bg-1', + // 'xterm-bg-2', + // 'xterm-bg-3', + // 'xterm-bg-4', + // 'xterm-bg-5', + // 'xterm-bg-6' + // ]); + // }); + // }); + + // it('selection', async () => { + // await openTerminal(page, { rows: 5, cols: 5 }); + // await writeSync(page, `\\n\\nfoo\\n\\n\\rbar\\n\\n\\rbaz`); + // assert.equal(await page.evaluate(`window.term.hasSelection()`), false); + // assert.equal(await page.evaluate(`window.term.getSelection()`), ''); + // assert.deepEqual(await page.evaluate(`window.term.getSelectionPosition()`), undefined); + // await page.evaluate(`window.term.selectAll()`); + // assert.equal(await page.evaluate(`window.term.hasSelection()`), true); + // if (process.platform === 'win32') { + // assert.equal(await page.evaluate(`window.term.getSelection()`), '\r\n\r\nfoo\r\n\r\nbar\r\n\r\nbaz'); + // } else { + // assert.equal(await page.evaluate(`window.term.getSelection()`), '\n\nfoo\n\nbar\n\nbaz'); + // } + // assert.deepEqual(await page.evaluate(`window.term.getSelectionPosition()`), { startColumn: 0, startRow: 0, endColumn: 5, endRow: 6 }); + // await page.evaluate(`window.term.clearSelection()`); + // assert.equal(await page.evaluate(`window.term.hasSelection()`), false); + // assert.equal(await page.evaluate(`window.term.getSelection()`), ''); + // assert.deepEqual(await page.evaluate(`window.term.getSelectionPosition()`), undefined); + // await page.evaluate(`window.term.select(1, 2, 2)`); + // assert.equal(await page.evaluate(`window.term.hasSelection()`), true); + // assert.equal(await page.evaluate(`window.term.getSelection()`), 'oo'); + // assert.deepEqual(await page.evaluate(`window.term.getSelectionPosition()`), { startColumn: 1, startRow: 2, endColumn: 3, endRow: 2 }); + // }); + + // it('focus, blur', async () => { + // await openTerminal(page); + // assert.equal(await page.evaluate(`document.activeElement.className`), ''); + // await page.evaluate(`window.term.focus()`); + // assert.equal(await page.evaluate(`document.activeElement.className`), 'xterm-helper-textarea'); + // await page.evaluate(`window.term.blur()`); + // assert.equal(await page.evaluate(`document.activeElement.className`), ''); + // }); + + // describe('loadAddon', () => { + // it('constructor', async () => { + // await openTerminal(page, { cols: 5 }); + // await page.evaluate(` + // window.cols = 0; + // window.term.loadAddon({ + // activate: (t) => window.cols = t.cols, + // dispose: () => {} + // }); + // `); + // assert.equal(await page.evaluate(`window.cols`), 5); + // }); + + // it('dispose (addon)', async () => { + // await openTerminal(page); + // await page.evaluate(` + // window.disposeCalled = false + // window.addon = { + // activate: () => {}, + // dispose: () => window.disposeCalled = true + // }; + // window.term.loadAddon(window.addon); + // `); + // assert.equal(await page.evaluate(`window.disposeCalled`), false); + // await page.evaluate(`window.addon.dispose()`); + // assert.equal(await page.evaluate(`window.disposeCalled`), true); + // }); + + // it('dispose (terminal)', async () => { + // await openTerminal(page); + // await page.evaluate(` + // window.disposeCalled = false + // window.term.loadAddon({ + // activate: () => {}, + // dispose: () => window.disposeCalled = true + // }); + // `); + // assert.equal(await page.evaluate(`window.disposeCalled`), false); + // await page.evaluate(`window.term.dispose()`); + // assert.equal(await page.evaluate(`window.disposeCalled`), true); + // }); + // }); + + // describe('Events', () => { + // it('onCursorMove', async () => { + // await openTerminal(page); + // await page.evaluate(` + // window.callCount = 0; + // window.term.onCursorMove(e => window.callCount++); + // window.term.write('foo'); + // `); + // await pollFor(page, `window.callCount`, 1); + // await page.evaluate(`window.term.write('bar')`); + // await pollFor(page, `window.callCount`, 2); + // }); + + // it('onData', async () => { + // await openTerminal(page); + // await page.evaluate(` + // window.calls = []; + // window.term.onData(e => calls.push(e)); + // `); + // await page.type('.xterm-helper-textarea', 'foo'); + // assert.deepEqual(await page.evaluate(`window.calls`), ['f', 'o', 'o']); + // }); + + // it('onKey', async () => { + // await openTerminal(page); + // await page.evaluate(` + // window.calls = []; + // window.term.onKey(e => calls.push(e.key)); + // `); + // await page.type('.xterm-helper-textarea', 'foo'); + // assert.deepEqual(await page.evaluate(`window.calls`), ['f', 'o', 'o']); + // }); + + // it('onLineFeed', async () => { + // await openTerminal(page); + // await page.evaluate(` + // window.callCount = 0; + // window.term.onLineFeed(() => callCount++); + // window.term.writeln('foo'); + // `); + // await pollFor(page, `window.callCount`, 1); + // await page.evaluate(`window.term.writeln('bar')`); + // await pollFor(page, `window.callCount`, 2); + // }); + + // it('onScroll', async () => { + // await openTerminal(page, { rows: 5 }); + // await page.evaluate(` + // window.calls = []; + // window.term.onScroll(e => window.calls.push(e)); + // for (let i = 0; i < 4; i++) { + // window.term.writeln('foo'); + // } + // `); + // await pollFor(page, `window.calls`, []); + // await page.evaluate(`window.term.writeln('bar')`); + // await pollFor(page, `window.calls`, [1]); + // await page.evaluate(`window.term.writeln('baz')`); + // await pollFor(page, `window.calls`, [1, 2]); + // }); + + // it('onSelectionChange', async () => { + // await openTerminal(page); + // await page.evaluate(` + // window.callCount = 0; + // window.term.onSelectionChange(() => window.callCount++); + // `); + // await pollFor(page, `window.callCount`, 0); + // await page.evaluate(`window.term.selectAll()`); + // await pollFor(page, `window.callCount`, 1); + // await page.evaluate(`window.term.clearSelection()`); + // await pollFor(page, `window.callCount`, 2); + // }); + + // it('onRender', async function(): Promise { + // this.retries(3); + // await openTerminal(page); + // await timeout(20); // Ensure all init events are fired + // await page.evaluate(` + // window.calls = []; + // window.term.onRender(e => window.calls.push([e.start, e.end])); + // `); + // await pollFor(page, `window.calls`, []); + // await page.evaluate(`window.term.write('foo')`); + // await pollFor(page, `window.calls`, [[0, 0]]); + // await page.evaluate(`window.term.write('bar\\n\\nbaz')`); + // await pollFor(page, `window.calls`, [[0, 0], [0, 2]]); + // }); + + // it('onResize', async () => { + // await openTerminal(page); + // await timeout(20); // Ensure all init events are fired + // await page.evaluate(` + // window.calls = []; + // window.term.onResize(e => window.calls.push([e.cols, e.rows])); + // `); + // await pollFor(page, `window.calls`, []); + // await page.evaluate(`window.term.resize(10, 5)`); + // await pollFor(page, `window.calls`, [[10, 5]]); + // await page.evaluate(`window.term.resize(20, 15)`); + // await pollFor(page, `window.calls`, [[10, 5], [20, 15]]); + // }); + + // it('onTitleChange', async () => { + // await openTerminal(page); + // await page.evaluate(` + // window.calls = []; + // window.term.onTitleChange(e => window.calls.push(e)); + // `); + // await pollFor(page, `window.calls`, []); + // await page.evaluate(`window.term.write('\\x1b]2;foo\\x9c')`); + // await pollFor(page, `window.calls`, ['foo']); + // }); + // it('onBell', async () => { + // await openTerminal(page); + // await page.evaluate(` + // window.calls = []; + // window.term.onBell(() => window.calls.push(true)); + // `); + // await pollFor(page, `window.calls`, []); + // await page.evaluate(`window.term.write('\\x07')`); + // await pollFor(page, `window.calls`, [true]); + // }); + // }); + + // describe('buffer', () => { + // it('cursorX, cursorY', async () => { + // await openTerminal(page, { rows: 5, cols: 5 }); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 0); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 0); + // await writeSync(page, 'foo'); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 3); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 0); + // await writeSync(page, '\\n'); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 3); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 1); + // await writeSync(page, '\\r'); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 0); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 1); + // await writeSync(page, 'abcde'); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 5); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 1); + // await writeSync(page, '\\n\\r\\n\\n\\n\\n\\n'); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 0); + // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 4); + // }); + + // it('viewportY', async () => { + // await openTerminal(page, { rows: 5 }); + // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 0); + // await writeSync(page, '\\n\\n\\n\\n'); + // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 0); + // await writeSync(page, '\\n'); + // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 1); + // await writeSync(page, '\\n\\n\\n\\n'); + // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 5); + // await page.evaluate(`window.term.scrollLines(-1)`); + // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 4); + // await page.evaluate(`window.term.scrollToTop()`); + // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 0); + // }); + + // it('baseY', async () => { + // await openTerminal(page, { rows: 5 }); + // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 0); + // await writeSync(page, '\\n\\n\\n\\n'); + // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 0); + // await writeSync(page, '\\n'); + // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 1); + // await writeSync(page, '\\n\\n\\n\\n'); + // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 5); + // await page.evaluate(`window.term.scrollLines(-1)`); + // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 5); + // await page.evaluate(`window.term.scrollToTop()`); + // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 5); + // }); + + // it('length', async () => { + // await openTerminal(page, { rows: 5 }); + // assert.equal(await page.evaluate(`window.term.buffer.active.length`), 5); + // await writeSync(page, '\\n\\n\\n\\n'); + // assert.equal(await page.evaluate(`window.term.buffer.active.length`), 5); + // await writeSync(page, '\\n'); + // assert.equal(await page.evaluate(`window.term.buffer.active.length`), 6); + // await writeSync(page, '\\n\\n\\n\\n'); + // assert.equal(await page.evaluate(`window.term.buffer.active.length`), 10); + // }); + + // describe('getLine', () => { + // it('invalid index', async () => { + // await openTerminal(page, { rows: 5 }); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(-1)`), undefined); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(5)`), undefined); + // }); + + // it('isWrapped', async () => { + // await openTerminal(page, { cols: 5 }); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).isWrapped`), false); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(1).isWrapped`), false); + // await writeSync(page, 'abcde'); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).isWrapped`), false); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(1).isWrapped`), false); + // await writeSync(page, 'f'); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).isWrapped`), false); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(1).isWrapped`), true); + // }); + + // it('translateToString', async () => { + // await openTerminal(page, { cols: 5 }); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), ' '); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString(true)`), ''); + // await writeSync(page, 'foo'); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), 'foo '); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString(true)`), 'foo'); + // await writeSync(page, 'bar'); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), 'fooba'); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString(true)`), 'fooba'); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(1).translateToString(true)`), 'r'); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString(false, 1)`), 'ooba'); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString(false, 1, 3)`), 'oo'); + // }); + + // it('getCell', async () => { + // await openTerminal(page, { cols: 5 }); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(-1)`), undefined); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(5)`), undefined); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(0).getChars()`), ''); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(0).getWidth()`), 1); + // await writeSync(page, 'a文'); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(0).getChars()`), 'a'); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(0).getWidth()`), 1); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(1).getChars()`), '文'); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(1).getWidth()`), 2); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(2).getChars()`), ''); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(2).getWidth()`), 0); + // }); + // }); + + // it('active, normal, alternate', async () => { + // await openTerminal(page, { cols: 5 }); + // assert.equal(await page.evaluate(`window.term.buffer.active.type`), 'normal'); + // assert.equal(await page.evaluate(`window.term.buffer.normal.type`), 'normal'); + // assert.equal(await page.evaluate(`window.term.buffer.alternate.type`), 'alternate'); + + // await writeSync(page, 'norm '); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), 'norm '); + // assert.equal(await page.evaluate(`window.term.buffer.normal.getLine(0).translateToString()`), 'norm '); + // assert.equal(await page.evaluate(`window.term.buffer.alternate.getLine(0)`), undefined); + + // await writeSync(page, '\\x1b[?47h\\r'); // use alternate screen buffer + // assert.equal(await page.evaluate(`window.term.buffer.active.type`), 'alternate'); + // assert.equal(await page.evaluate(`window.term.buffer.normal.type`), 'normal'); + // assert.equal(await page.evaluate(`window.term.buffer.alternate.type`), 'alternate'); + + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), ' '); + // await writeSync(page, 'alt '); + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), 'alt '); + // assert.equal(await page.evaluate(`window.term.buffer.normal.getLine(0).translateToString()`), 'norm '); + // assert.equal(await page.evaluate(`window.term.buffer.alternate.getLine(0).translateToString()`), 'alt '); + + // await writeSync(page, '\\x1b[?47l\\r'); // use normal screen buffer + // assert.equal(await page.evaluate(`window.term.buffer.active.type`), 'normal'); + // assert.equal(await page.evaluate(`window.term.buffer.normal.type`), 'normal'); + // assert.equal(await page.evaluate(`window.term.buffer.alternate.type`), 'alternate'); + + // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), 'norm '); + // assert.equal(await page.evaluate(`window.term.buffer.normal.getLine(0).translateToString()`), 'norm '); + // assert.equal(await page.evaluate(`window.term.buffer.alternate.getLine(0)`), undefined); + // }); + // }); + + // it('dispose', async () => { + // await page.evaluate(` + // window.term = new Terminal(); + // window.term.dispose(); + // `); + // assert.equal(await page.evaluate(`window.term._core._isDisposed`), true); + // }); + + // it('dispose (opened)', async () => { + // await openTerminal(page); + // await page.evaluate(`window.term.dispose()`); + // assert.equal(await page.evaluate(`window.term._core._isDisposed`), true); + // }); +}); + +function writeSync(text: string | Uint8Array): Promise { + return new Promise(r => term.write(text, r)); +} + +function writelnSync(text: string | Uint8Array): Promise { + return new Promise(r => term.writeln(text, r)); +} + +function lineEquals(index: number, text: string): void { + strictEqual(term.buffer.active.getLine(index)!.translateToString(true), text); +} diff --git a/test/api/Terminal.api.ts b/test/api/Terminal.api.ts index 9e951ffef..75399b733 100644 --- a/test/api/Terminal.api.ts +++ b/test/api/Terminal.api.ts @@ -69,12 +69,9 @@ describe('API Integration Tests', function(): void { it('write - bytes (UTF8)', async () => { await openTerminal(page); await page.evaluate(` - // foo - window.term.write(new Uint8Array([102, 111, 111])); - // bar - window.term.write(new Uint8Array([98, 97, 114])); - // 文 - window.term.write(new Uint8Array([230, 150, 135])); + window.term.write(new Uint8Array([102, 111, 111])); // foo + window.term.write(new Uint8Array([98, 97, 114])); // bar + window.term.write(new Uint8Array([230, 150, 135])); // 文 `); await pollFor(page, `window.term.buffer.active.getLine(0).translateToString(true)`, 'foobar文'); }); @@ -82,12 +79,9 @@ describe('API Integration Tests', function(): void { it('write - bytes (UTF8) with callback', async () => { await openTerminal(page); await page.evaluate(` - // foo - window.term.write(new Uint8Array([102, 111, 111]), () => { window.__x = 'A'; }); - // bar - window.term.write(new Uint8Array([98, 97, 114]), () => { window.__x += 'B'; }); - // 文 - window.term.write(new Uint8Array([230, 150, 135]), () => { window.__x += 'C'; }); + window.term.write(new Uint8Array([102, 111, 111]), () => { window.__x = 'A'; }); // foo + window.term.write(new Uint8Array([98, 97, 114]), () => { window.__x += 'B'; }); // bar + window.term.write(new Uint8Array([230, 150, 135]), () => { window.__x += 'C'; }); // 文 `); await pollFor(page, `window.term.buffer.active.getLine(0).translateToString(true)`, 'foobar文'); await pollFor(page, `window.__x`, 'ABC'); From df48e9f6d5f54f30ad4b2fe15f0d978f68adef9d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 12 Aug 2021 05:52:40 -0700 Subject: [PATCH 071/164] Headless event tests --- src/browser/public/Terminal.ts | 14 +- src/headless/public/Terminal.test.ts | 348 ++++++++------------------- src/headless/public/Terminal.ts | 10 +- typings/xterm-headless.d.ts | 13 + typings/xterm.d.ts | 38 +-- 5 files changed, 143 insertions(+), 280 deletions(-) diff --git a/src/browser/public/Terminal.ts b/src/browser/public/Terminal.ts index 8b7b5d2ee..6af9db71e 100644 --- a/src/browser/public/Terminal.ts +++ b/src/browser/public/Terminal.ts @@ -30,17 +30,17 @@ export class Terminal implements ITerminalApi { } } - public get onCursorMove(): IEvent { return this._core.onCursorMove; } - public get onLineFeed(): IEvent { return this._core.onLineFeed; } - public get onSelectionChange(): IEvent { return this._core.onSelectionChange; } - public get onData(): IEvent { return this._core.onData; } - public get onBinary(): IEvent { return this._core.onBinary; } - public get onTitleChange(): IEvent { return this._core.onTitleChange; } public get onBell(): IEvent { return this._core.onBell; } - public get onScroll(): IEvent { return this._core.onScroll; } + public get onBinary(): IEvent { return this._core.onBinary; } + public get onCursorMove(): IEvent { return this._core.onCursorMove; } + public get onData(): IEvent { return this._core.onData; } public get onKey(): IEvent<{ key: string, domEvent: KeyboardEvent }> { return this._core.onKey; } + public get onLineFeed(): IEvent { return this._core.onLineFeed; } public get onRender(): IEvent<{ start: number, end: number }> { return this._core.onRender; } public get onResize(): IEvent<{ cols: number, rows: number }> { return this._core.onResize; } + public get onScroll(): IEvent { return this._core.onScroll; } + public get onSelectionChange(): IEvent { return this._core.onSelectionChange; } + public get onTitleChange(): IEvent { return this._core.onTitleChange; } public get element(): HTMLElement | undefined { return this._core.element; } public get parser(): IParser { diff --git a/src/headless/public/Terminal.test.ts b/src/headless/public/Terminal.test.ts index 9f45b78ed..f70a8127f 100644 --- a/src/headless/public/Terminal.test.ts +++ b/src/headless/public/Terminal.test.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { strictEqual, throws } from 'assert'; +import { deepStrictEqual, strictEqual, throws } from 'assert'; import { Terminal } from 'headless/public/Terminal'; let term: Terminal; @@ -113,265 +113,113 @@ describe.only('Headless API Tests', function(): void { } }); - // it('getOption, setOption', async () => { - // await openTerminal(page); - // assert.equal(await page.evaluate(`window.term.getOption('rendererType')`), 'canvas'); - // await page.evaluate(`window.term.setOption('rendererType', 'dom')`); - // assert.equal(await page.evaluate(`window.term.getOption('rendererType')`), 'dom'); - // }); + it('getOption, setOption', async () => { + strictEqual(term.getOption('scrollback'), 1000); + term.setOption('scrollback', 50); + strictEqual(term.getOption('scrollback'), 50); + }); - // describe('renderer', () => { - // it('foreground', async () => { - // await openTerminal(page, { rendererType: 'dom' }); - // await writeSync(page, '\\x1b[30m0\\x1b[31m1\\x1b[32m2\\x1b[33m3\\x1b[34m4\\x1b[35m5\\x1b[36m6\\x1b[37m7'); - // await pollFor(page, `document.querySelectorAll('.xterm-rows > :nth-child(1) > *').length`, 9); - // assert.deepEqual(await page.evaluate(` - // [ - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(1)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(2)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(3)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(4)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(5)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(6)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(7)').className - // ] - // `), [ - // 'xterm-fg-0', - // 'xterm-fg-1', - // 'xterm-fg-2', - // 'xterm-fg-3', - // 'xterm-fg-4', - // 'xterm-fg-5', - // 'xterm-fg-6' - // ]); - // }); + describe('loadAddon', () => { + it('constructor', async () => { + term = new Terminal({ cols: 5 }); + let cols = 0; + term.loadAddon({ + activate: (t) => cols = t.cols, + dispose: () => {} + }); + strictEqual(cols, 5); + }); - // it('background', async () => { - // await openTerminal(page, { rendererType: 'dom' }); - // await writeSync(page, '\\x1b[40m0\\x1b[41m1\\x1b[42m2\\x1b[43m3\\x1b[44m4\\x1b[45m5\\x1b[46m6\\x1b[47m7'); - // await pollFor(page, `document.querySelectorAll('.xterm-rows > :nth-child(1) > *').length`, 9); - // assert.deepEqual(await page.evaluate(` - // [ - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(1)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(2)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(3)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(4)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(5)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(6)').className, - // document.querySelector('.xterm-rows > :nth-child(1) > :nth-child(7)').className - // ] - // `), [ - // 'xterm-bg-0', - // 'xterm-bg-1', - // 'xterm-bg-2', - // 'xterm-bg-3', - // 'xterm-bg-4', - // 'xterm-bg-5', - // 'xterm-bg-6' - // ]); - // }); - // }); + it('dispose (addon)', async () => { + let disposeCalled = false; + const addon = { + activate: () => {}, + dispose: () => disposeCalled = true + }; + term.loadAddon(addon); + strictEqual(disposeCalled, false); + addon.dispose(); + strictEqual(disposeCalled, true); + }); - // it('selection', async () => { - // await openTerminal(page, { rows: 5, cols: 5 }); - // await writeSync(page, `\\n\\nfoo\\n\\n\\rbar\\n\\n\\rbaz`); - // assert.equal(await page.evaluate(`window.term.hasSelection()`), false); - // assert.equal(await page.evaluate(`window.term.getSelection()`), ''); - // assert.deepEqual(await page.evaluate(`window.term.getSelectionPosition()`), undefined); - // await page.evaluate(`window.term.selectAll()`); - // assert.equal(await page.evaluate(`window.term.hasSelection()`), true); - // if (process.platform === 'win32') { - // assert.equal(await page.evaluate(`window.term.getSelection()`), '\r\n\r\nfoo\r\n\r\nbar\r\n\r\nbaz'); - // } else { - // assert.equal(await page.evaluate(`window.term.getSelection()`), '\n\nfoo\n\nbar\n\nbaz'); - // } - // assert.deepEqual(await page.evaluate(`window.term.getSelectionPosition()`), { startColumn: 0, startRow: 0, endColumn: 5, endRow: 6 }); - // await page.evaluate(`window.term.clearSelection()`); - // assert.equal(await page.evaluate(`window.term.hasSelection()`), false); - // assert.equal(await page.evaluate(`window.term.getSelection()`), ''); - // assert.deepEqual(await page.evaluate(`window.term.getSelectionPosition()`), undefined); - // await page.evaluate(`window.term.select(1, 2, 2)`); - // assert.equal(await page.evaluate(`window.term.hasSelection()`), true); - // assert.equal(await page.evaluate(`window.term.getSelection()`), 'oo'); - // assert.deepEqual(await page.evaluate(`window.term.getSelectionPosition()`), { startColumn: 1, startRow: 2, endColumn: 3, endRow: 2 }); - // }); + it('dispose (terminal)', async () => { + let disposeCalled = false; + term.loadAddon({ + activate: () => {}, + dispose: () => disposeCalled = true + }); + strictEqual(disposeCalled, false); + term.dispose(); + strictEqual(disposeCalled, true); + }); + }); - // it('focus, blur', async () => { - // await openTerminal(page); - // assert.equal(await page.evaluate(`document.activeElement.className`), ''); - // await page.evaluate(`window.term.focus()`); - // assert.equal(await page.evaluate(`document.activeElement.className`), 'xterm-helper-textarea'); - // await page.evaluate(`window.term.blur()`); - // assert.equal(await page.evaluate(`document.activeElement.className`), ''); - // }); + describe('Events', () => { + it('onCursorMove', async () => { + let callCount = 0; + term.onCursorMove(e => callCount++); + await writeSync('foo'); + strictEqual(callCount, 1); + await writeSync('bar'); + strictEqual(callCount, 2); + }); - // describe('loadAddon', () => { - // it('constructor', async () => { - // await openTerminal(page, { cols: 5 }); - // await page.evaluate(` - // window.cols = 0; - // window.term.loadAddon({ - // activate: (t) => window.cols = t.cols, - // dispose: () => {} - // }); - // `); - // assert.equal(await page.evaluate(`window.cols`), 5); - // }); + it('onData', async () => { + const calls: string[] = []; + term.onData(e => calls.push(e)); + await writeSync('\x1b[5n'); // DSR Status Report + deepStrictEqual(calls, ['\x1b[0n']); + }); - // it('dispose (addon)', async () => { - // await openTerminal(page); - // await page.evaluate(` - // window.disposeCalled = false - // window.addon = { - // activate: () => {}, - // dispose: () => window.disposeCalled = true - // }; - // window.term.loadAddon(window.addon); - // `); - // assert.equal(await page.evaluate(`window.disposeCalled`), false); - // await page.evaluate(`window.addon.dispose()`); - // assert.equal(await page.evaluate(`window.disposeCalled`), true); - // }); + it('onLineFeed', async () => { + let callCount = 0; + term.onLineFeed(() => callCount++); + await writelnSync('foo'); + strictEqual(callCount, 1); + await writelnSync('bar'); + strictEqual(callCount, 2); + }); - // it('dispose (terminal)', async () => { - // await openTerminal(page); - // await page.evaluate(` - // window.disposeCalled = false - // window.term.loadAddon({ - // activate: () => {}, - // dispose: () => window.disposeCalled = true - // }); - // `); - // assert.equal(await page.evaluate(`window.disposeCalled`), false); - // await page.evaluate(`window.term.dispose()`); - // assert.equal(await page.evaluate(`window.disposeCalled`), true); - // }); - // }); + it('onScroll', async () => { + term = new Terminal({ rows: 5 }); + const calls: number[] = []; + term.onScroll(e => calls.push(e)); + for (let i = 0; i < 4; i++) { + await writelnSync('foo'); + } + deepStrictEqual(calls, []); + await writelnSync('bar'); + deepStrictEqual(calls, [1]); + await writelnSync('baz'); + deepStrictEqual(calls, [1, 2]); + }); - // describe('Events', () => { - // it('onCursorMove', async () => { - // await openTerminal(page); - // await page.evaluate(` - // window.callCount = 0; - // window.term.onCursorMove(e => window.callCount++); - // window.term.write('foo'); - // `); - // await pollFor(page, `window.callCount`, 1); - // await page.evaluate(`window.term.write('bar')`); - // await pollFor(page, `window.callCount`, 2); - // }); + it('onResize', async () => { + const calls: [number, number][] = []; + term.onResize(e => calls.push([e.cols, e.rows])); + deepStrictEqual(calls, []); + term.resize(10, 5); + deepStrictEqual(calls, [[10, 5]]); + term.resize(20, 15); + deepStrictEqual(calls, [[10, 5], [20, 15]]); + }); - // it('onData', async () => { - // await openTerminal(page); - // await page.evaluate(` - // window.calls = []; - // window.term.onData(e => calls.push(e)); - // `); - // await page.type('.xterm-helper-textarea', 'foo'); - // assert.deepEqual(await page.evaluate(`window.calls`), ['f', 'o', 'o']); - // }); + it('onTitleChange', async () => { + const calls: string[] = []; + term.onTitleChange(e => calls.push(e)); + deepStrictEqual(calls, []); + await writeSync('\x1b]2;foo\x9c'); + deepStrictEqual(calls, ['foo']); + }); - // it('onKey', async () => { - // await openTerminal(page); - // await page.evaluate(` - // window.calls = []; - // window.term.onKey(e => calls.push(e.key)); - // `); - // await page.type('.xterm-helper-textarea', 'foo'); - // assert.deepEqual(await page.evaluate(`window.calls`), ['f', 'o', 'o']); - // }); - - // it('onLineFeed', async () => { - // await openTerminal(page); - // await page.evaluate(` - // window.callCount = 0; - // window.term.onLineFeed(() => callCount++); - // window.term.writeln('foo'); - // `); - // await pollFor(page, `window.callCount`, 1); - // await page.evaluate(`window.term.writeln('bar')`); - // await pollFor(page, `window.callCount`, 2); - // }); - - // it('onScroll', async () => { - // await openTerminal(page, { rows: 5 }); - // await page.evaluate(` - // window.calls = []; - // window.term.onScroll(e => window.calls.push(e)); - // for (let i = 0; i < 4; i++) { - // window.term.writeln('foo'); - // } - // `); - // await pollFor(page, `window.calls`, []); - // await page.evaluate(`window.term.writeln('bar')`); - // await pollFor(page, `window.calls`, [1]); - // await page.evaluate(`window.term.writeln('baz')`); - // await pollFor(page, `window.calls`, [1, 2]); - // }); - - // it('onSelectionChange', async () => { - // await openTerminal(page); - // await page.evaluate(` - // window.callCount = 0; - // window.term.onSelectionChange(() => window.callCount++); - // `); - // await pollFor(page, `window.callCount`, 0); - // await page.evaluate(`window.term.selectAll()`); - // await pollFor(page, `window.callCount`, 1); - // await page.evaluate(`window.term.clearSelection()`); - // await pollFor(page, `window.callCount`, 2); - // }); - - // it('onRender', async function(): Promise { - // this.retries(3); - // await openTerminal(page); - // await timeout(20); // Ensure all init events are fired - // await page.evaluate(` - // window.calls = []; - // window.term.onRender(e => window.calls.push([e.start, e.end])); - // `); - // await pollFor(page, `window.calls`, []); - // await page.evaluate(`window.term.write('foo')`); - // await pollFor(page, `window.calls`, [[0, 0]]); - // await page.evaluate(`window.term.write('bar\\n\\nbaz')`); - // await pollFor(page, `window.calls`, [[0, 0], [0, 2]]); - // }); - - // it('onResize', async () => { - // await openTerminal(page); - // await timeout(20); // Ensure all init events are fired - // await page.evaluate(` - // window.calls = []; - // window.term.onResize(e => window.calls.push([e.cols, e.rows])); - // `); - // await pollFor(page, `window.calls`, []); - // await page.evaluate(`window.term.resize(10, 5)`); - // await pollFor(page, `window.calls`, [[10, 5]]); - // await page.evaluate(`window.term.resize(20, 15)`); - // await pollFor(page, `window.calls`, [[10, 5], [20, 15]]); - // }); - - // it('onTitleChange', async () => { - // await openTerminal(page); - // await page.evaluate(` - // window.calls = []; - // window.term.onTitleChange(e => window.calls.push(e)); - // `); - // await pollFor(page, `window.calls`, []); - // await page.evaluate(`window.term.write('\\x1b]2;foo\\x9c')`); - // await pollFor(page, `window.calls`, ['foo']); - // }); - // it('onBell', async () => { - // await openTerminal(page); - // await page.evaluate(` - // window.calls = []; - // window.term.onBell(() => window.calls.push(true)); - // `); - // await pollFor(page, `window.calls`, []); - // await page.evaluate(`window.term.write('\\x07')`); - // await pollFor(page, `window.calls`, [true]); - // }); - // }); + it('onBell', async () => { + const calls: boolean[] = []; + term.onBell(() => calls.push(true)); + deepStrictEqual(calls, []); + await writeSync('\x07'); + deepStrictEqual(calls, [true]); + }); + }); // describe('buffer', () => { // it('cursorX, cursorY', async () => { diff --git a/src/headless/public/Terminal.ts b/src/headless/public/Terminal.ts index f14bdd559..7a92da15c 100644 --- a/src/headless/public/Terminal.ts +++ b/src/headless/public/Terminal.ts @@ -28,12 +28,14 @@ export class Terminal implements ITerminalApi { } } - public get onCursorMove(): IEvent { return this._core.onCursorMove; } - public get onLineFeed(): IEvent { return this._core.onLineFeed; } - public get onData(): IEvent { return this._core.onData; } + public get onBell(): IEvent { return this._core.onBell; } public get onBinary(): IEvent { return this._core.onBinary; } - public get onTitleChange(): IEvent { return this._core.onTitleChange; } + public get onCursorMove(): IEvent { return this._core.onCursorMove; } + public get onData(): IEvent { return this._core.onData; } + public get onLineFeed(): IEvent { return this._core.onLineFeed; } public get onResize(): IEvent<{ cols: number, rows: number }> { return this._core.onResize; } + public get onScroll(): IEvent { return this._core.onScroll; } + public get onTitleChange(): IEvent { return this._core.onTitleChange; } public get parser(): IParser { this._checkProposedApi(); diff --git a/typings/xterm-headless.d.ts b/typings/xterm-headless.d.ts index 3dd9d69e1..66d8f1918 100644 --- a/typings/xterm-headless.d.ts +++ b/typings/xterm-headless.d.ts @@ -533,6 +533,12 @@ declare module 'xterm-headless' { */ constructor(options?: ITerminalOptions); + /** + * Adds an event listener for when the bell is triggered. + * @returns an `IDisposable` to stop listening. + */ + onBell: IEvent; + /** * Adds an event listener for when a binary event fires. This is used to * enable non UTF-8 conformant binary messages to be sent to the backend. @@ -572,6 +578,13 @@ declare module 'xterm-headless' { */ onResize: IEvent<{ cols: number, rows: number }>; + /** + * Adds an event listener for when a scroll occurs. The event value is the + * new position of the viewport. + * @returns an `IDisposable` to stop listening. + */ + onScroll: IEvent; + /** * Adds an event listener for when an OSC 0 or OSC 2 title change occurs. * The event value is the new title. diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 6bfb71ae0..035748fcb 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -634,6 +634,12 @@ declare module 'xterm' { */ constructor(options?: ITerminalOptions); + /** + * Adds an event listener for when the bell is triggered. + * @returns an `IDisposable` to stop listening. + */ + onBell: IEvent; + /** * Adds an event listener for when a binary event fires. This is used to * enable non UTF-8 conformant binary messages to be sent to the backend. @@ -674,19 +680,6 @@ declare module 'xterm' { */ onLineFeed: IEvent; - /** - * Adds an event listener for when a scroll occurs. The event value is the - * new position of the viewport. - * @returns an `IDisposable` to stop listening. - */ - onScroll: IEvent; - - /** - * Adds an event listener for when a selection change occurs. - * @returns an `IDisposable` to stop listening. - */ - onSelectionChange: IEvent; - /** * Adds an event listener for when rows are rendered. The event value * contains the start row and end rows of the rendered area (ranges from `0` @@ -702,6 +695,19 @@ declare module 'xterm' { */ onResize: IEvent<{ cols: number, rows: number }>; + /** + * Adds an event listener for when a scroll occurs. The event value is the + * new position of the viewport. + * @returns an `IDisposable` to stop listening. + */ + onScroll: IEvent; + + /** + * Adds an event listener for when a selection change occurs. + * @returns an `IDisposable` to stop listening. + */ + onSelectionChange: IEvent; + /** * Adds an event listener for when an OSC 0 or OSC 2 title change occurs. * The event value is the new title. @@ -709,12 +715,6 @@ declare module 'xterm' { */ onTitleChange: IEvent; - /** - * Adds an event listener for when the bell is triggered. - * @returns an `IDisposable` to stop listening. - */ - onBell: IEvent; - /** * Unfocus the terminal. */ From f8066d6dee944799fc10ae118501f6515ca16700 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 12 Aug 2021 06:00:55 -0700 Subject: [PATCH 072/164] Full tests for xterm-headless --- src/headless/public/Terminal.test.ts | 283 +++++++++++++-------------- src/headless/public/Terminal.ts | 18 ++ typings/xterm-headless.d.ts | 28 +++ 3 files changed, 183 insertions(+), 146 deletions(-) diff --git a/src/headless/public/Terminal.test.ts b/src/headless/public/Terminal.test.ts index f70a8127f..15e1efbac 100644 --- a/src/headless/public/Terminal.test.ts +++ b/src/headless/public/Terminal.test.ts @@ -8,7 +8,7 @@ import { Terminal } from 'headless/public/Terminal'; let term: Terminal; -describe.only('Headless API Tests', function(): void { +describe('Headless API Tests', function(): void { beforeEach(() => { // Create default terminal to be used by most tests term = new Terminal(); @@ -221,165 +221,156 @@ describe.only('Headless API Tests', function(): void { }); }); - // describe('buffer', () => { - // it('cursorX, cursorY', async () => { - // await openTerminal(page, { rows: 5, cols: 5 }); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 0); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 0); - // await writeSync(page, 'foo'); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 3); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 0); - // await writeSync(page, '\\n'); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 3); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 1); - // await writeSync(page, '\\r'); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 0); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 1); - // await writeSync(page, 'abcde'); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 5); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 1); - // await writeSync(page, '\\n\\r\\n\\n\\n\\n\\n'); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorX`), 0); - // assert.equal(await page.evaluate(`window.term.buffer.active.cursorY`), 4); - // }); + describe('buffer', () => { + it('cursorX, cursorY', async () => { + term = new Terminal({ rows: 5, cols: 5 }); + strictEqual(term.buffer.active.cursorX, 0); + strictEqual(term.buffer.active.cursorY, 0); + await writeSync('foo'); + strictEqual(term.buffer.active.cursorX, 3); + strictEqual(term.buffer.active.cursorY, 0); + await writeSync('\n'); + strictEqual(term.buffer.active.cursorX, 3); + strictEqual(term.buffer.active.cursorY, 1); + await writeSync('\r'); + strictEqual(term.buffer.active.cursorX, 0); + strictEqual(term.buffer.active.cursorY, 1); + await writeSync('abcde'); + strictEqual(term.buffer.active.cursorX, 5); + strictEqual(term.buffer.active.cursorY, 1); + await writeSync('\n\r\n\n\n\n\n'); + strictEqual(term.buffer.active.cursorX, 0); + strictEqual(term.buffer.active.cursorY, 4); + }); - // it('viewportY', async () => { - // await openTerminal(page, { rows: 5 }); - // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 0); - // await writeSync(page, '\\n\\n\\n\\n'); - // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 0); - // await writeSync(page, '\\n'); - // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 1); - // await writeSync(page, '\\n\\n\\n\\n'); - // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 5); - // await page.evaluate(`window.term.scrollLines(-1)`); - // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 4); - // await page.evaluate(`window.term.scrollToTop()`); - // assert.equal(await page.evaluate(`window.term.buffer.active.viewportY`), 0); - // }); + it('viewportY', async () => { + term = new Terminal({ rows: 5 }); + strictEqual(term.buffer.active.viewportY, 0); + await writeSync('\n\n\n\n'); + strictEqual(term.buffer.active.viewportY, 0); + await writeSync('\n'); + strictEqual(term.buffer.active.viewportY, 1); + await writeSync('\n\n\n\n'); + strictEqual(term.buffer.active.viewportY, 5); + term.scrollLines(-1); + strictEqual(term.buffer.active.viewportY, 4); + term.scrollToTop(); + strictEqual(term.buffer.active.viewportY, 0); + }); - // it('baseY', async () => { - // await openTerminal(page, { rows: 5 }); - // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 0); - // await writeSync(page, '\\n\\n\\n\\n'); - // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 0); - // await writeSync(page, '\\n'); - // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 1); - // await writeSync(page, '\\n\\n\\n\\n'); - // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 5); - // await page.evaluate(`window.term.scrollLines(-1)`); - // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 5); - // await page.evaluate(`window.term.scrollToTop()`); - // assert.equal(await page.evaluate(`window.term.buffer.active.baseY`), 5); - // }); + it('baseY', async () => { + term = new Terminal({ rows: 5 }); + strictEqual(term.buffer.active.baseY, 0); + await writeSync('\n\n\n\n'); + strictEqual(term.buffer.active.baseY, 0); + await writeSync('\n'); + strictEqual(term.buffer.active.baseY, 1); + await writeSync('\n\n\n\n'); + strictEqual(term.buffer.active.baseY, 5); + term.scrollLines(-1); + strictEqual(term.buffer.active.baseY, 5); + term.scrollToTop(); + strictEqual(term.buffer.active.baseY, 5); + }); - // it('length', async () => { - // await openTerminal(page, { rows: 5 }); - // assert.equal(await page.evaluate(`window.term.buffer.active.length`), 5); - // await writeSync(page, '\\n\\n\\n\\n'); - // assert.equal(await page.evaluate(`window.term.buffer.active.length`), 5); - // await writeSync(page, '\\n'); - // assert.equal(await page.evaluate(`window.term.buffer.active.length`), 6); - // await writeSync(page, '\\n\\n\\n\\n'); - // assert.equal(await page.evaluate(`window.term.buffer.active.length`), 10); - // }); + it('length', async () => { + term = new Terminal({ rows: 5 }); + strictEqual(term.buffer.active.length, 5); + await writeSync('\n\n\n\n'); + strictEqual(term.buffer.active.length, 5); + await writeSync('\n'); + strictEqual(term.buffer.active.length, 6); + await writeSync('\n\n\n\n'); + strictEqual(term.buffer.active.length, 10); + }); - // describe('getLine', () => { - // it('invalid index', async () => { - // await openTerminal(page, { rows: 5 }); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(-1)`), undefined); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(5)`), undefined); - // }); + describe('getLine', () => { + it('invalid index', async () => { + term = new Terminal({ rows: 5 }); + strictEqual(term.buffer.active.getLine(-1), undefined); + strictEqual(term.buffer.active.getLine(5), undefined); + }); - // it('isWrapped', async () => { - // await openTerminal(page, { cols: 5 }); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).isWrapped`), false); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(1).isWrapped`), false); - // await writeSync(page, 'abcde'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).isWrapped`), false); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(1).isWrapped`), false); - // await writeSync(page, 'f'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).isWrapped`), false); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(1).isWrapped`), true); - // }); + it('isWrapped', async () => { + term = new Terminal({ cols: 5 }); + strictEqual(term.buffer.active.getLine(0)!.isWrapped, false); + strictEqual(term.buffer.active.getLine(1)!.isWrapped, false); + await writeSync('abcde'); + strictEqual(term.buffer.active.getLine(0)!.isWrapped, false); + strictEqual(term.buffer.active.getLine(1)!.isWrapped, false); + await writeSync('f'); + strictEqual(term.buffer.active.getLine(0)!.isWrapped, false); + strictEqual(term.buffer.active.getLine(1)!.isWrapped, true); + }); - // it('translateToString', async () => { - // await openTerminal(page, { cols: 5 }); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), ' '); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString(true)`), ''); - // await writeSync(page, 'foo'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), 'foo '); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString(true)`), 'foo'); - // await writeSync(page, 'bar'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), 'fooba'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString(true)`), 'fooba'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(1).translateToString(true)`), 'r'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString(false, 1)`), 'ooba'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString(false, 1, 3)`), 'oo'); - // }); + it('translateToString', async () => { + term = new Terminal({ cols: 5 }); + strictEqual(term.buffer.active.getLine(0)!.translateToString(), ' '); + strictEqual(term.buffer.active.getLine(0)!.translateToString(true), ''); + await writeSync('foo'); + strictEqual(term.buffer.active.getLine(0)!.translateToString(), 'foo '); + strictEqual(term.buffer.active.getLine(0)!.translateToString(true), 'foo'); + await writeSync('bar'); + strictEqual(term.buffer.active.getLine(0)!.translateToString(), 'fooba'); + strictEqual(term.buffer.active.getLine(0)!.translateToString(true), 'fooba'); + strictEqual(term.buffer.active.getLine(1)!.translateToString(true), 'r'); + strictEqual(term.buffer.active.getLine(0)!.translateToString(false, 1), 'ooba'); + strictEqual(term.buffer.active.getLine(0)!.translateToString(false, 1, 3), 'oo'); + }); - // it('getCell', async () => { - // await openTerminal(page, { cols: 5 }); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(-1)`), undefined); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(5)`), undefined); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(0).getChars()`), ''); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(0).getWidth()`), 1); - // await writeSync(page, 'a文'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(0).getChars()`), 'a'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(0).getWidth()`), 1); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(1).getChars()`), '文'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(1).getWidth()`), 2); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(2).getChars()`), ''); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).getCell(2).getWidth()`), 0); - // }); - // }); + it('getCell', async () => { + term = new Terminal({ cols: 5 }); + strictEqual(term.buffer.active.getLine(0)!.getCell(-1), undefined); + strictEqual(term.buffer.active.getLine(0)!.getCell(5), undefined); + strictEqual(term.buffer.active.getLine(0)!.getCell(0)!.getChars(), ''); + strictEqual(term.buffer.active.getLine(0)!.getCell(0)!.getWidth(), 1); + await writeSync('a文'); + strictEqual(term.buffer.active.getLine(0)!.getCell(0)!.getChars(), 'a'); + strictEqual(term.buffer.active.getLine(0)!.getCell(0)!.getWidth(), 1); + strictEqual(term.buffer.active.getLine(0)!.getCell(1)!.getChars(), '文'); + strictEqual(term.buffer.active.getLine(0)!.getCell(1)!.getWidth(), 2); + strictEqual(term.buffer.active.getLine(0)!.getCell(2)!.getChars(), ''); + strictEqual(term.buffer.active.getLine(0)!.getCell(2)!.getWidth(), 0); + }); + }); - // it('active, normal, alternate', async () => { - // await openTerminal(page, { cols: 5 }); - // assert.equal(await page.evaluate(`window.term.buffer.active.type`), 'normal'); - // assert.equal(await page.evaluate(`window.term.buffer.normal.type`), 'normal'); - // assert.equal(await page.evaluate(`window.term.buffer.alternate.type`), 'alternate'); + it('active, normal, alternate', async () => { + term = new Terminal({ cols: 5 }); + strictEqual(term.buffer.active.type, 'normal'); + strictEqual(term.buffer.normal.type, 'normal'); + strictEqual(term.buffer.alternate.type, 'alternate'); - // await writeSync(page, 'norm '); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), 'norm '); - // assert.equal(await page.evaluate(`window.term.buffer.normal.getLine(0).translateToString()`), 'norm '); - // assert.equal(await page.evaluate(`window.term.buffer.alternate.getLine(0)`), undefined); + await writeSync('norm '); + strictEqual(term.buffer.active.getLine(0)!.translateToString(), 'norm '); + strictEqual(term.buffer.normal.getLine(0)!.translateToString(), 'norm '); + strictEqual(term.buffer.alternate.getLine(0), undefined); - // await writeSync(page, '\\x1b[?47h\\r'); // use alternate screen buffer - // assert.equal(await page.evaluate(`window.term.buffer.active.type`), 'alternate'); - // assert.equal(await page.evaluate(`window.term.buffer.normal.type`), 'normal'); - // assert.equal(await page.evaluate(`window.term.buffer.alternate.type`), 'alternate'); + await writeSync('\x1b[?47h\r'); // use alternate screen buffer + strictEqual(term.buffer.active.type, 'alternate'); + strictEqual(term.buffer.normal.type, 'normal'); + strictEqual(term.buffer.alternate.type, 'alternate'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), ' '); - // await writeSync(page, 'alt '); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), 'alt '); - // assert.equal(await page.evaluate(`window.term.buffer.normal.getLine(0).translateToString()`), 'norm '); - // assert.equal(await page.evaluate(`window.term.buffer.alternate.getLine(0).translateToString()`), 'alt '); + strictEqual(term.buffer.active.getLine(0)!.translateToString(), ' '); + await writeSync('alt '); + strictEqual(term.buffer.active.getLine(0)!.translateToString(), 'alt '); + strictEqual(term.buffer.normal.getLine(0)!.translateToString(), 'norm '); + strictEqual(term.buffer.alternate.getLine(0)!.translateToString(), 'alt '); - // await writeSync(page, '\\x1b[?47l\\r'); // use normal screen buffer - // assert.equal(await page.evaluate(`window.term.buffer.active.type`), 'normal'); - // assert.equal(await page.evaluate(`window.term.buffer.normal.type`), 'normal'); - // assert.equal(await page.evaluate(`window.term.buffer.alternate.type`), 'alternate'); + await writeSync('\x1b[?47l\r'); // use normal screen buffer + strictEqual(term.buffer.active.type, 'normal'); + strictEqual(term.buffer.normal.type, 'normal'); + strictEqual(term.buffer.alternate.type, 'alternate'); - // assert.equal(await page.evaluate(`window.term.buffer.active.getLine(0).translateToString()`), 'norm '); - // assert.equal(await page.evaluate(`window.term.buffer.normal.getLine(0).translateToString()`), 'norm '); - // assert.equal(await page.evaluate(`window.term.buffer.alternate.getLine(0)`), undefined); - // }); - // }); + strictEqual(term.buffer.active.getLine(0)!.translateToString(), 'norm '); + strictEqual(term.buffer.normal.getLine(0)!.translateToString(), 'norm '); + strictEqual(term.buffer.alternate.getLine(0), undefined); + }); + }); - // it('dispose', async () => { - // await page.evaluate(` - // window.term = new Terminal(); - // window.term.dispose(); - // `); - // assert.equal(await page.evaluate(`window.term._core._isDisposed`), true); - // }); - - // it('dispose (opened)', async () => { - // await openTerminal(page); - // await page.evaluate(`window.term.dispose()`); - // assert.equal(await page.evaluate(`window.term._core._isDisposed`), true); - // }); + it('dispose', async () => { + term.dispose(); + strictEqual((term as any)._core._isDisposed, true); + }); }); function writeSync(text: string | Uint8Array): Promise { diff --git a/src/headless/public/Terminal.ts b/src/headless/public/Terminal.ts index 7a92da15c..a1de7fdb1 100644 --- a/src/headless/public/Terminal.ts +++ b/src/headless/public/Terminal.ts @@ -77,6 +77,24 @@ export class Terminal implements ITerminalApi { 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(); } diff --git a/typings/xterm-headless.d.ts b/typings/xterm-headless.d.ts index 66d8f1918..03e7567a7 100644 --- a/typings/xterm-headless.d.ts +++ b/typings/xterm-headless.d.ts @@ -620,6 +620,34 @@ declare module 'xterm-headless' { */ dispose(): void; + /** + * Scroll the display of the terminal + * @param amount The number of lines to scroll down (negative scroll up). + */ + scrollLines(amount: number): void; + + /** + * Scroll the display of the terminal by a number of pages. + * @param pageCount The number of pages to scroll (negative scrolls up). + */ + scrollPages(pageCount: number): void; + + /** + * Scrolls the display of the terminal to the top. + */ + scrollToTop(): void; + + /** + * Scrolls the display of the terminal to the bottom. + */ + scrollToBottom(): void; + + /** + * Scrolls to a line within the buffer. + * @param line The 0-based line index to scroll to. + */ + scrollToLine(line: number): void; + /** * Clear the entire buffer, making the prompt line the new first line. */ From f45f5b4b9f7f9923124f44f9f5d71afbde6ad068 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 12 Aug 2021 06:11:30 -0700 Subject: [PATCH 073/164] Remove unneeded manual headless test --- headless/test/README.md | 9 --------- headless/test/index.js | 12 ------------ headless/test/package.json | 11 ----------- 3 files changed, 32 deletions(-) delete mode 100644 headless/test/README.md delete mode 100644 headless/test/index.js delete mode 100644 headless/test/package.json diff --git a/headless/test/README.md b/headless/test/README.md deleted file mode 100644 index e48da411e..000000000 --- a/headless/test/README.md +++ /dev/null @@ -1,9 +0,0 @@ -This is a basic manual test for 'xterm-headless': - -```sh -# From repo root -yarn build -yarn package-headless -cd headless/test -node index.js -``` diff --git a/headless/test/index.js b/headless/test/index.js deleted file mode 100644 index 021f2ecd4..000000000 --- a/headless/test/index.js +++ /dev/null @@ -1,12 +0,0 @@ -import { createRequire } from 'module'; -const require = createRequire(import.meta.url); -const Terminal = require('../headless/lib-headless/xterm.js').Terminal; - -console.log('Creating xterm-headless terminal...'); -const terminal = new Terminal(); -console.log('Writing to terminal...') -terminal.write('foo \x1b[1;31mbar\x1b[0m baz', () => { - const bufferLine = terminal.buffer.normal.getLine(terminal.buffer.normal.cursorY); - const contents = bufferLine.translateToString(true); - console.log(`Contents of terminal active buffer are: ${contents}`); // foo bar baz -}); diff --git a/headless/test/package.json b/headless/test/package.json deleted file mode 100644 index 935496233..000000000 --- a/headless/test/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "test", - "version": "1.0.0", - "description": "", - "main": "index.js", - "type": "module", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "" -} From d694febdbff05268c99a048663be2f82d9fde4bc Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 12 Aug 2021 06:19:15 -0700 Subject: [PATCH 074/164] Polish readme --- headless/README.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/headless/README.md b/headless/README.md index 358c97efb..1d2d61568 100644 --- a/headless/README.md +++ b/headless/README.md @@ -1,5 +1,31 @@ # [![xterm.js logo](logo-full.png)](https://xtermjs.org) -⚠ This package is a work in progress +⚠ This package is experimental `xterm-headless` is a headless terminal that can be run in node.js. This is useful in combination with the frontend [`xterm`](https://www.npmjs.com/package/xterm) for example to keep track of a terminal's state on a remote server where the process is hosted. + +## Getting Started + +First, you need to install the module, we ship exclusively through npm, so you need that installed and then add xterm.js as a dependency by running: + +```sh +npm install xterm-headless +``` + +Then import as you would a regular node package. The recommended way to load `xterm-headless` is with TypeScript and the ES6 module syntax: + +```javascript +import { Terminal } from 'xterm-headless'; +``` + +## API + +The full API for `xterm-headless` is contained within the [TypeScript declaration file](https://github.com/xtermjs/xterm.js/blob/master/typings/xterm-headless.d.ts), use the branch/tag picker in GitHub (`w`) to navigate to the correct version of the API. + +Note that some APIs are marked *experimental*, these are added to enable experimentation with new ideas without committing to support it like a normal [semver](https://semver.org/) API. Note that these APIs can change radically between versions, so be sure to read release notes if you plan on using experimental APIs. + +### Addons + +Addons in `xterm-headless` work the [same as in `xterm`](https://github.com/xtermjs/xterm.js/blob/master/README.md#addons) with the one caveat being that the addon needs to be packaged for node.js and not use any DOM APIs. + +Currently no official addons are packaged on npm. From 7f5af09f52279bb973c614ce907c0332fcf6447a Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 12 Aug 2021 06:53:59 -0700 Subject: [PATCH 075/164] Include lib-headless in xterm-headless Part of #3212 --- headless/.npmignore | 1 + 1 file changed, 1 insertion(+) diff --git a/headless/.npmignore b/headless/.npmignore index c6b33260f..83e9f2019 100644 --- a/headless/.npmignore +++ b/headless/.npmignore @@ -1,5 +1,6 @@ # Include !typings/*.d.ts +!lib-headless/ # Exclude test/ From 0a287e01abcf82eb8bebf049f084abdb5c0cef44 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 12 Aug 2021 07:20:38 -0700 Subject: [PATCH 076/164] Run yarn package before publishing Part of #2749 --- azure-pipelines.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c87496b2b..5d4e99180 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -164,7 +164,9 @@ jobs: displayName: Cache node modules - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - - script: node ./bin/package_headless.js + - script: | + yarn package-headless + node ./bin/package_headless.js displayName: 'Package xterm-headless' - script: NPM_AUTH_TOKEN="$(NPM_AUTH_TOKEN)" node ./bin/publish.js displayName: 'Package and publish to npm' From d13afa1b37afc43f505ed573db576a469c75e2cf Mon Sep 17 00:00:00 2001 From: meganrogge Date: Thu, 12 Aug 2021 10:12:43 -0700 Subject: [PATCH 077/164] get things to work Co-authored-by: Daniel Imms --- src/browser/renderer/BaseRenderLayer.ts | 6 ++--- src/browser/renderer/BoxAndBlockCharacters.ts | 25 +++++++++++++++---- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 39819353e..3d0128fee 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -412,7 +412,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { if (!lineSegments) { return false; } - const xOffset = x * this._scaledCellWidth + this._scaledCharLeft; + const xOffset = x * this._scaledCellWidth; const verticalCenter = Math.round(this._scaledCellHeight / 2); const yOffset = y * this._scaledCellHeight + this._scaledCharTop + verticalCenter; @@ -420,10 +420,10 @@ export abstract class BaseRenderLayer implements IRenderLayer { this._ctx.strokeStyle = this._ctx.fillStyle; // increase # of pixels when font size incremented by 10 - this._ctx.lineWidth = Math.max(Math.floor(this._optionsService.options.fontSize / 10), 1); + // this._ctx.lineWidth = Math.max(Math.floor(this._optionsService.options.fontSize / 10), 1); const horizontalCenter = Math.round(this._scaledCellWidth / 2); // yOffset - verticalCenter - draw(this._ctx, char, xOffset, y * this._scaledCellHeight + this._scaledCharTop, this._scaledCellWidth, this._scaledCellHeight); + draw(this._ctx, char, xOffset, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); return true; diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 379bc2d78..0bbc487fa 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -372,6 +372,7 @@ export function draw(ctx: CanvasRenderingContext2D, c: string, xOffset: number, } const lineWidth = ctx.lineWidth; const instructions = entry.split(' '); + for (const instruction of instructions) { const type = instruction[0]; const spec = instructionMap[type]; @@ -379,17 +380,31 @@ export function draw(ctx: CanvasRenderingContext2D, c: string, xOffset: number, if (!coords[0] || !coords[1]) { continue; } - const numX = Number.parseFloat(coords[0].toString()) || Number.parseInt(coords[0].toString()); - const numY = Number.parseFloat(coords[1].toString()) || Number.parseInt(coords[1].toString()); + let numX = Number.parseFloat(coords[0].toString()) || Number.parseInt(coords[0].toString()); + let numY = Number.parseFloat(coords[1].toString()) || Number.parseInt(coords[1].toString()); if (instruction.endsWith(THICK)) { - ctx.lineWidth = lineWidth * 2; + ctx.lineWidth = window.devicePixelRatio * 2; } else { - ctx.lineWidth = lineWidth; + ctx.lineWidth = window.devicePixelRatio; } - spec(ctx, xOffset + Math.round((numX) * cellWidth), yOffset + ((numY)) * cellHeight); + + numX *= cellWidth; + numY *= cellHeight; + + if (numY !== 0) { + numY = clamp(Math.round(numY + .5) - .5, cellHeight, 0); + } + if (numX !== 0) { + numX = clamp(Math.round(numX + .5) - .5, cellWidth, 0); + } + spec(ctx, xOffset + numX, yOffset + numY); } } +function clamp(value: number, max: number, min: number = 0): number { + return Math.max(Math.min(value, max), min); +} + const instructionMap: { [index: string]: any } = { 'M': (ctx: CanvasRenderingContext2D, x: number, y: number) => { ctx.beginPath(); From 91043858837b64d3c402d14d95d7686c9069baf0 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Thu, 12 Aug 2021 11:38:45 -0700 Subject: [PATCH 078/164] convert a bunch of them --- src/browser/renderer/BaseRenderLayer.ts | 67 --- src/browser/renderer/BoxAndBlockCharacters.ts | 515 +++++++++++++----- 2 files changed, 364 insertions(+), 218 deletions(-) diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 3d0128fee..31773f643 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -421,76 +421,9 @@ export abstract class BaseRenderLayer implements IRenderLayer { // increase # of pixels when font size incremented by 10 // this._ctx.lineWidth = Math.max(Math.floor(this._optionsService.options.fontSize / 10), 1); - const horizontalCenter = Math.round(this._scaledCellWidth / 2); // yOffset - verticalCenter draw(this._ctx, char, xOffset, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); return true; - - - // // TODO: Clean below - // const scale = window.devicePixelRatio; - // this._ctx.strokeStyle = this._ctx.fillStyle; - - // // increase # of pixels when font size incremented by 10 - // this._ctx.lineWidth = Math.max(Math.floor(this._optionsService.options.fontSize / 10), 1); - - // const xOffset = x * this._scaledCellWidth + this._scaledCharLeft; - // const yOffset = y * this._scaledCellHeight + this._scaledCharTop; - // const horizontalCenter = Math.round(this._scaledCellWidth / 2); - // const verticalCenter = Math.round(this._scaledCellHeight / 2); - // const xPoints = [ - // xOffset, - // xOffset + horizontalCenter - scale * 2, - // xOffset + horizontalCenter - scale, - // xOffset + horizontalCenter, - // xOffset + horizontalCenter + scale, - // xOffset + horizontalCenter + scale * 2, - // xOffset + this._scaledCellWidth - // ]; - // const yPoints = [ - // yOffset - 1, - // yOffset + verticalCenter - scale * 2, - // yOffset + verticalCenter - scale, - // yOffset + verticalCenter, - // yOffset + verticalCenter + scale, - // yOffset + verticalCenter + scale * 2, - // yOffset + this._scaledCellHeight - // ]; - - // for (let i = 0; i < lineSegments.length; i++) { - // const line = lineSegments[i]; - - // if (i === 0 || (line.x1 !== lineSegments[i - 1].x2 || line.y1 !== lineSegments[i - 1].y2)) { - // this._ctx.beginPath(); - // if (this._ctx.lineWidth % 2 === 1) { - // this._ctx.moveTo(line.x1 === 0 ? xPoints[line.x1] : xPoints[line.x1] + .5, yPoints[line.y1] + .5); - // } else { - // this._ctx.moveTo(xPoints[line.x1], yPoints[line.y1]); - // } - // } - - // if (typeof line.cx1 !== 'undefined') { - // // Draw curve - // this._ctx.bezierCurveTo( - // xPoints[line.cx1], - // yPoints[line.cy1], - // xPoints[line.cx2], - // yPoints[line.cy2], - // xPoints[line.x2], - // yPoints[line.y2]); - // } else { - // // Draw line - // if (this._ctx.lineWidth % 2 === 1) { - // this._ctx.lineTo(line.x2 === 0 ? xPoints[line.x2] : xPoints[line.x2] + .5, yPoints[line.y2] + .5); - // } else { - // this._ctx.lineTo(xPoints[line.x2], yPoints[line.y2]); - // } - // } - - // this._ctx.stroke(); - // } - - // return true; } diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 0bbc487fa..1b6fef41a 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -243,161 +243,378 @@ const topYAxisFromMiddle = `${MOVE}${CENTER.TOP} ${TO}${CENTER.MIDDLE}`; const rightMiddleXAxis = `${MOVE}${CENTER.MIDDLE} ${TO}${RIGHT.MIDDLE}`; const leftMiddleXAxis = `${MOVE}${CENTER.MIDDLE} ${TO}${LEFT.MIDDLE}`; -export const chars: { [index: string]: string } = { - '━': `${xAxis}`, - '│': `${yAxis}`, - '┃': `${yAxis}${THICK}`, - '┌': `${bottomYAxisFromBottom} ${TO}${RIGHT.MIDDLE}`, - '┍': `${bottomYAxisFromBottom} ${TO}${RIGHT.MIDDLE}${THICK}`, - '┎': `${bottomYAxisFromBottom}${THICK} ${TO}${RIGHT.MIDDLE}`, - '┏': `${bottomYAxisFromBottom}${THICK} ${TO}${RIGHT.MIDDLE}${THICK}`, - '┐': `${bottomYAxisFromBottom} ${TO}${LEFT.MIDDLE}`, - '┑': `${bottomYAxisFromBottom} ${TO}${LEFT.MIDDLE}${THICK}`, - '┒': `${bottomYAxisFromBottom}${THICK} ${TO}${LEFT.MIDDLE}`, - '┓': `${bottomYAxisFromBottom}${THICK} ${TO}${LEFT.MIDDLE}${THICK}`, - '└': `${topYAxisFromTop} ${TO}${RIGHT.MIDDLE}`, - '┕': `${topYAxisFromTop} ${TO}${RIGHT.MIDDLE}${THICK}`, - '┖': `${topYAxisFromTop}${THICK} ${TO}${RIGHT.MIDDLE}`, - '┗': `${topYAxisFromTop}${THICK} ${TO}${RIGHT.MIDDLE}${THICK}`, - '┘': `${topYAxisFromTop} ${TO}${LEFT.MIDDLE}`, - '┙': `${topYAxisFromTop} ${TO}${LEFT.MIDDLE}${THICK}`, - '┚': `${topYAxisFromTop}${THICK} ${TO}${LEFT.MIDDLE}`, - '┛': `${topYAxisFromTop}${THICK} ${TO}${LEFT.MIDDLE}${THICK}`, - '├': `${yAxis} ${rightMiddleXAxis}`, - '┝': `${yAxis} ${rightMiddleXAxis}${THICK}`, - '┞': `${topYAxisFromTop}${THICK} ${bottomYAxisFromMiddle} ${rightMiddleXAxis}`, - '┟': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${rightMiddleXAxis}${THICK}`, - '┠': `${yAxis}${THICK} ${rightMiddleXAxis}`, - '┡': `${bottomYAxisFromBottom} ${topYAxisFromMiddle}${THICK} ${rightMiddleXAxis}${THICK}`, - '┢': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${rightMiddleXAxis}${THICK}`, - '┣': `${yAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - '┤': `${yAxis} ${leftMiddleXAxis}`, - '┥': `${yAxis} ${leftMiddleXAxis}${THICK}`, - '┦': `${topYAxisFromTop}${THICK} ${bottomYAxisFromMiddle} ${leftMiddleXAxis}`, - '┧': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${leftMiddleXAxis}${THICK}`, - '┨': `${yAxis}${THICK} ${leftMiddleXAxis}`, - '┩': `${bottomYAxisFromBottom} ${topYAxisFromMiddle}${THICK} ${leftMiddleXAxis}${THICK}`, - '┪': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${leftMiddleXAxis}${THICK}`, - '┫': `${yAxis}${THICK} ${leftMiddleXAxis}${THICK}`, - '┬': `${bottomYAxisFromBottom} ${xAxis}`, - '┭': `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - '┮': `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - '┯': `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - '┰': `${bottomYAxisFromBottom}${THICK} ${xAxis}`, - '┱': `${bottomYAxisFromBottom}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - '┲': `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - '┳': `${bottomYAxisFromBottom}${THICK} ${xAxis}${THICK}`, - '┴': `${topYAxisFromTop} ${xAxis}`, - '┵': `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - '┶': `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - '┷': `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - '┸': `${topYAxisFromTop}${THICK} ${xAxis}`, - '┹': `${topYAxisFromTop}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - '┺': `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - '┻': `${topYAxisFromTop}${THICK} ${xAxis}${THICK}`, - '┼': `${yAxis} ${xAxis}`, - '┽': `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - '┾': `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - '┿': `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - '╀': `${yAxis}${THICK} ${xAxis}`, - '╁': `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - '╂': `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - '╃': `${yAxis}${THICK} ${xAxis}${THICK}`, - '╄': `${yAxis} ${xAxis}`, - '╅': `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - '╆': `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - '╇': `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - '╈': `${yAxis}${THICK} ${xAxis}`, - '╉': `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - '╊': `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - '╋': `${yAxis}${THICK} ${xAxis}${THICK}`, - '╌': `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}`, - '╍': `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'}${THICK} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}${THICK}`, - '╎':`${MOVE}${CENTER.TOP} ${TO}${'.5,.47'} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}`, - '╏':`${MOVE}${CENTER.TOP} ${TO}${'.5,.47'}${THICK} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}${THICK}`, - // '═': `${MOVE}${} ${TO}${} ${TO}${}`, - // '║': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╒': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╓': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╔': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╕': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╖': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╗': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╘': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╙': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╚': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╛': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╜': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╝': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╞': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╟': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╠': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╡': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╢': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╣': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╤': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╥': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╦': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╧': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╨': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╩': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╪': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╫': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╬': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╭': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╮': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╯': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╰': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╱': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╲': `${MOVE}${} ${TO}${} ${TO}${}`, - // '╳': `${MOVE}${} ${TO}${} ${TO}${}`, - '╴': `${leftMiddleXAxis}`, - '╵': `${topYAxisFromMiddle}`, - '╶': `${rightMiddleXAxis}`, - '╷': `${bottomYAxisFromMiddle}`, - '╸': `${leftMiddleXAxis}${THICK}`, - '╹': `${topYAxisFromMiddle}${THICK}`, - '╺': `${rightMiddleXAxis}${THICK}`, - '╻': `${bottomYAxisFromMiddle}${THICK}`, - '╼': `${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - '╽': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle}`, - '╾': `${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - '╿': `${bottomYAxisFromBottom} ${topYAxisFromMiddle}${THICK}` +const map: { [character: string]: { [fontWeight: number]: string } } = { + '━': { + 1: `${xAxis}` + }, + '│': { + 1: `${yAxis}` + }, + '┃': { + 2: `${yAxis}` + }, + '┌': { + 1: `${bottomYAxisFromBottom} ${TO}${RIGHT.MIDDLE}` + }, + '┍': { + 1: `${bottomYAxisFromBottom}`, + 2: `${rightMiddleXAxis}` + }, + '┎': { + 1: `${rightMiddleXAxis}`, + 2: `${bottomYAxisFromBottom}` + }, + '┏': { + 2: `${bottomYAxisFromBottom} ${TO}${RIGHT.MIDDLE}` + }, + '┐': { + 1: `${bottomYAxisFromBottom} ${TO}${LEFT.MIDDLE}` + }, + '┑': { + 1: `${bottomYAxisFromBottom}`, + 2: `${leftMiddleXAxis}` + }, + '┒': { + 1: `${leftMiddleXAxis}`, + 2: `${bottomYAxisFromBottom}` + }, + '┓': { + 2: `${bottomYAxisFromBottom} ${TO}${LEFT.MIDDLE}` + }, + '└': { + 1: `${topYAxisFromTop} ${TO}${RIGHT.MIDDLE}` + }, + '┕': { + 1: `${topYAxisFromTop}`, + 2: `${rightMiddleXAxis}` + }, + '┖': { + 1: `${rightMiddleXAxis}`, + 2: `${topYAxisFromTop}` + }, + '┗': { + 2: `${topYAxisFromTop} ${TO}${RIGHT.MIDDLE}` + }, + '┘': { + 1: `${topYAxisFromTop} ${TO}${LEFT.MIDDLE}` + }, + '┙': { + 1: `${topYAxisFromTop}`, + 2: `${leftMiddleXAxis}` + }, + '┚': { + 1: `${leftMiddleXAxis}`, + 2: `${topYAxisFromTop}` + }, + '┛': { + 2: `${topYAxisFromTop} ${TO}${LEFT.MIDDLE}` + }, + '├': { + 1: `${yAxis} ${rightMiddleXAxis}` + }, + '┝': { + 1: `${yAxis}`, + 2: `${rightMiddleXAxis}` + }, + '┞': { + 1: `${bottomYAxisFromMiddle} ${rightMiddleXAxis}`, + 2: `${topYAxisFromTop}` + }, + '┟': { + 1: `${topYAxisFromMiddle} ${rightMiddleXAxis}`, + 2: `${bottomYAxisFromBottom}` + }, + '┠': { + 1: `${rightMiddleXAxis}`, + 2: `${yAxis}` + }, + '┡': { + 1: `${bottomYAxisFromBottom}`, + 2: `${topYAxisFromMiddle} ${rightMiddleXAxis}` + }, + '┢': { + 1: `${topYAxisFromMiddle}`, + 2: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` + }, + '┣': { + 2: `${yAxis} ${rightMiddleXAxis}` + }, + '┤': { + 1: `${yAxis} ${leftMiddleXAxis}` + }, + '┥': { + 1: `${yAxis}`, + 2: `${leftMiddleXAxis}` + }, + '┦': { + 1: `${bottomYAxisFromMiddle} ${leftMiddleXAxis}`, + 2: `${topYAxisFromTop}` + }, + '┧': { + 1: `${topYAxisFromMiddle}`, + 2: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` + }, + '┨': { + 1: `${leftMiddleXAxis}`, + 2: `${yAxis}` + }, + '┩': { + 2: `${topYAxisFromMiddle} ${leftMiddleXAxis}`, + 1: `${bottomYAxisFromMiddle}` + } +}; + +const chars: { [index: string]: string } = { + + + // } // '┩{ + // 1: ': `${leftMiddleXAxis}${THICK} ${topYAxisFromMiddle}${THICK} ${MOVE}${CENTER.MIDDLE} ${bottomYAxisFromMiddle + // 1: ': `${leftMiddleXAxis}${THICK} ${topYAxisFromMiddle}${THICK} ${MOVE}${CENTER.MIDDLE} ${bottomYAxisFromMiddle + // }`, + + // } '┪': { + // 1: `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${leftMiddleXAxis}${THICK}`, + // 1: `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${leftMiddleXAxis}${THICK}`, + // } + // '┫': { + // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK}`, + // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK}`, + // } + // '┬': { + // 1: `${bottomYAxisFromBottom} ${xAxis}`, + // 1: `${bottomYAxisFromBottom} ${xAxis}`, + // } + // '┭': { + // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // } + // '┮': { + // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // } + // '┯': { + // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + // } + // '┰': { + // 1: `${bottomYAxisFromBottom}${THICK} ${xAxis}`, + // 1: `${bottomYAxisFromBottom}${THICK} ${xAxis}`, + // } + // '┱': { + // 1: `${bottomYAxisFromBottom}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // 1: `${bottomYAxisFromBottom}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // } + // '┲': { + // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // } + // '┳': { + // 1: `${bottomYAxisFromBottom}${THICK} ${xAxis}${THICK}`, + // 1: `${bottomYAxisFromBottom}${THICK} ${xAxis}${THICK}`, + // } + // '┴': { + // 1: `${topYAxisFromTop} ${xAxis}`, + // 1: `${topYAxisFromTop} ${xAxis}`, + // } + // '┵': { + // 1: `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // 1: `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // } + // '┶': { + // 1: `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // 1: `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // } + // '┷': { + // 1: `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + // 1: `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + // } + // '┸': { + // 1: `${topYAxisFromTop}${THICK} ${xAxis}`, + // 1: `${topYAxisFromTop}${THICK} ${xAxis}`, + // } + // '┹': { + // 1: `${topYAxisFromTop}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // 1: `${topYAxisFromTop}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // } + // '┺': { + // 1: `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // 1: `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // } + // '┻': { + // 1: `${topYAxisFromTop}${THICK} ${xAxis}${THICK}`, + // 1: `${topYAxisFromTop}${THICK} ${xAxis}${THICK}`, + // } + // '┼': { + // 1: `${yAxis} ${xAxis}`, + // 1: `${yAxis} ${xAxis}`, + // } + // '┽': { + // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // } + // '┾': { + // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // } + // '┿': { + // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + // } + // '╀': { + // 1: `${yAxis}${THICK} ${xAxis}`, + // 1: `${yAxis}${THICK} ${xAxis}`, + // } + // '╁': { + // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // } + // '╂': { + // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // } + // '╃': { + // 1: `${yAxis}${THICK} ${xAxis}${THICK}`, + // 1: `${yAxis}${THICK} ${xAxis}${THICK}`, + // } + // '╄': { + // 1: `${yAxis} ${xAxis}`, + // 1: `${yAxis} ${xAxis}`, + // } + // '╅': { + // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // } + // '╆': { + // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // } + // '╇': { + // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, + // } + // '╈': { + // 1: `${yAxis}${THICK} ${xAxis}`, + // 1: `${yAxis}${THICK} ${xAxis}`, + // } + // '╉': { + // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, + // } + // '╊': { + // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, + // } + // '╋': { + // 1: `${yAxis}${THICK} ${xAxis}${THICK}`, + // 1: `${yAxis}${THICK} ${xAxis}${THICK}`, + // } + // '╌': { + // 1: `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}`, + // 1: `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}`, + // } + // '╍': { + // 1: `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'}${THICK} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}${THICK}`, + // 1: `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'}${THICK} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}${THICK}`, + // } + // '╎':`{ + // 1: ${MOVE}${CENTER.TOP} ${TO}${'.5,.47'} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}` + // 1: ${MOVE}${CENTER.TOP} ${TO}${'.5,.47'} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}` + // }, + // '╏':`{ + // 1: ${MOVE}${CENTER.TOP} ${TO}${'.5,.47'}${THICK} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}${THICK}` + // 1: ${MOVE}${CENTER.TOP} ${TO}${'.5,.47'}${THICK} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}${THICK}` + // }, + // // '═{ + // 1: ': `${MOVE}${} ${TO}${} ${TO}${ + // 1: ': `${MOVE}${} ${TO}${} ${TO}${ + + // }`, + + // } // '║{ + // 1: ': `${MOVE}${} ${TO}${} ${TO}${ + // 1: ': `${MOVE}${} ${TO}${} ${TO}${ + + // }`, + +// } // '╒': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╓': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╔': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╕': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╖': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╗': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╘': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╙': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╚': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╛': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╜': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╝': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╞': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╟': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╠': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╡': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╢': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╣': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╤': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╥': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╦': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╧': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╨': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╩': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╪': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╫': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╬': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╭': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╮': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╯': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╰': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╱': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╲': `${MOVE}${} ${TO}${} ${TO}${}`, +// // '╳': `${MOVE}${} ${TO}${} ${TO}${}`, +// '╴': `${leftMiddleXAxis}`, +// '╵': `${topYAxisFromMiddle}`, +// '╶': `${rightMiddleXAxis}`, +// '╷': `${bottomYAxisFromMiddle}`, +// '╸': `${leftMiddleXAxis}${THICK}`, +// '╹': `${topYAxisFromMiddle}${THICK}`, +// '╺': `${rightMiddleXAxis}${THICK}`, +// '╻': `${bottomYAxisFromMiddle}${THICK}`, +// '╼': `${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, +// '╽': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle}`, +// '╾': `${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, +// '╿': `${bottomYAxisFromBottom} ${topYAxisFromMiddle}${THICK}` }; export function draw(ctx: CanvasRenderingContext2D, c: string, xOffset: number, yOffset: number, cellWidth: number, cellHeight: number): void { - const entry = chars[c]; - if (!entry) { + const match: { [fontWeight: number]: string } = map[c]; + if (!match) { return; } - const lineWidth = ctx.lineWidth; - const instructions = entry.split(' '); + for (const [fontWeight, instructions] of Object.entries(match)) { + ctx.beginPath(); + ctx.lineWidth = window.devicePixelRatio * Number.parseInt(fontWeight); + for (const instruction of instructions.split(' ')) { + const type = instruction[0]; + const f = instructionMap[type]; + const coords: string[] = instruction.substring(1).split(','); + if (!coords[0] || !coords[1]) { + continue; + } + let x = Number.parseFloat(coords[0].toString()) || Number.parseInt(coords[0].toString()); + let y = Number.parseFloat(coords[1].toString()) || Number.parseInt(coords[1].toString()); - for (const instruction of instructions) { - const type = instruction[0]; - const spec = instructionMap[type]; - const coords: string[] = instruction.substring(1).split(','); - if (!coords[0] || !coords[1]) { - continue; - } - let numX = Number.parseFloat(coords[0].toString()) || Number.parseInt(coords[0].toString()); - let numY = Number.parseFloat(coords[1].toString()) || Number.parseInt(coords[1].toString()); - if (instruction.endsWith(THICK)) { - ctx.lineWidth = window.devicePixelRatio * 2; - } else { - ctx.lineWidth = window.devicePixelRatio; - } + x *= cellWidth; + y *= cellHeight; - numX *= cellWidth; - numY *= cellHeight; - - if (numY !== 0) { - numY = clamp(Math.round(numY + .5) - .5, cellHeight, 0); + if (y !== 0) { + y = clamp(Math.round(y + .5) - .5, cellHeight, 0); + } + if (x !== 0) { + x = clamp(Math.round(x + .5) - .5, cellWidth, 0); + } + f(ctx, xOffset + x, yOffset + y); } - if (numX !== 0) { - numX = clamp(Math.round(numX + .5) - .5, cellWidth, 0); - } - spec(ctx, xOffset + numX, yOffset + numY); + ctx.stroke(); + ctx.closePath(); } } @@ -407,13 +624,9 @@ function clamp(value: number, max: number, min: number = 0): number { const instructionMap: { [index: string]: any } = { 'M': (ctx: CanvasRenderingContext2D, x: number, y: number) => { - ctx.beginPath(); ctx.moveTo(x, y); }, 'L': (ctx: CanvasRenderingContext2D, x: number, y: number) => { ctx.lineTo(x, y); - ctx.stroke(); - ctx.beginPath(); - ctx.moveTo(x, y); } }; From 07513c927f851f47fd76ca8adf7cf9a8c2cdd4f8 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Thu, 12 Aug 2021 11:46:52 -0700 Subject: [PATCH 079/164] more --- src/browser/renderer/BoxAndBlockCharacters.ts | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 1b6fef41a..b6ac8dc9d 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -361,25 +361,17 @@ const map: { [character: string]: { [fontWeight: number]: string } } = { '┩': { 2: `${topYAxisFromMiddle} ${leftMiddleXAxis}`, 1: `${bottomYAxisFromMiddle}` + }, + '┪': { + 1: `${topYAxisFromMiddle}`, + 2: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` + }, + '┫': { + 2: `${yAxis} ${leftMiddleXAxis}` } }; const chars: { [index: string]: string } = { - - - // } // '┩{ - // 1: ': `${leftMiddleXAxis}${THICK} ${topYAxisFromMiddle}${THICK} ${MOVE}${CENTER.MIDDLE} ${bottomYAxisFromMiddle - // 1: ': `${leftMiddleXAxis}${THICK} ${topYAxisFromMiddle}${THICK} ${MOVE}${CENTER.MIDDLE} ${bottomYAxisFromMiddle - // }`, - - // } '┪': { - // 1: `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${leftMiddleXAxis}${THICK}`, - // 1: `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle} ${leftMiddleXAxis}${THICK}`, - // } - // '┫': { - // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK}`, - // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK}`, - // } // '┬': { // 1: `${bottomYAxisFromBottom} ${xAxis}`, // 1: `${bottomYAxisFromBottom} ${xAxis}`, From d8899b0b5d461bd2d1d3dd2c63e6ef4223f92d7e Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 12 Aug 2021 12:59:22 -0700 Subject: [PATCH 080/164] Fix eslint errors in test/benchmark --- .../EscapeSequenceParser.benchmark.ts | 172 +++++++++--------- test/benchmark/Terminal.benchmark.ts | 12 +- 2 files changed, 92 insertions(+), 92 deletions(-) diff --git a/test/benchmark/EscapeSequenceParser.benchmark.ts b/test/benchmark/EscapeSequenceParser.benchmark.ts index c2707f19b..10c447973 100644 --- a/test/benchmark/EscapeSequenceParser.benchmark.ts +++ b/test/benchmark/EscapeSequenceParser.benchmark.ts @@ -40,42 +40,42 @@ perfContext('Parser throughput - 50MB data', () => { beforeEach(() => { parser = new EscapeSequenceParser(); parser.setPrintHandler((data, start, end) => {}); - parser.registerCsiHandler({final: '@'}, params => true); - parser.registerCsiHandler({final: 'A'}, params => true); - parser.registerCsiHandler({final: 'B'}, params => true); - parser.registerCsiHandler({final: 'C'}, params => true); - parser.registerCsiHandler({final: 'D'}, params => true); - parser.registerCsiHandler({final: 'E'}, params => true); - parser.registerCsiHandler({final: 'F'}, params => true); - parser.registerCsiHandler({final: 'G'}, params => true); - parser.registerCsiHandler({final: 'H'}, params => true); - parser.registerCsiHandler({final: 'I'}, params => true); - parser.registerCsiHandler({final: 'J'}, params => true); - parser.registerCsiHandler({final: 'K'}, params => true); - parser.registerCsiHandler({final: 'L'}, params => true); - parser.registerCsiHandler({final: 'M'}, params => true); - parser.registerCsiHandler({final: 'P'}, params => true); - parser.registerCsiHandler({final: 'S'}, params => true); - parser.registerCsiHandler({final: 'T'}, params => true); - parser.registerCsiHandler({final: 'X'}, params => true); - parser.registerCsiHandler({final: 'Z'}, params => true); - parser.registerCsiHandler({final: '`'}, params => true); - parser.registerCsiHandler({final: 'a'}, params => true); - parser.registerCsiHandler({final: 'b'}, params => true); - parser.registerCsiHandler({final: 'c'}, params => true); - parser.registerCsiHandler({final: 'd'}, params => true); - parser.registerCsiHandler({final: 'e'}, params => true); - parser.registerCsiHandler({final: 'f'}, params => true); - parser.registerCsiHandler({final: 'g'}, params => true); - parser.registerCsiHandler({final: 'h'}, params => true); - parser.registerCsiHandler({final: 'l'}, params => true); - parser.registerCsiHandler({final: 'm'}, params => true); - parser.registerCsiHandler({final: 'n'}, params => true); - parser.registerCsiHandler({final: 'p'}, params => true); - parser.registerCsiHandler({final: 'q'}, params => true); - parser.registerCsiHandler({final: 'r'}, params => true); - parser.registerCsiHandler({final: 's'}, params => true); - parser.registerCsiHandler({final: 'u'}, params => true); + parser.registerCsiHandler({ final: '@' }, params => true); + parser.registerCsiHandler({ final: 'A' }, params => true); + parser.registerCsiHandler({ final: 'B' }, params => true); + parser.registerCsiHandler({ final: 'C' }, params => true); + parser.registerCsiHandler({ final: 'D' }, params => true); + parser.registerCsiHandler({ final: 'E' }, params => true); + parser.registerCsiHandler({ final: 'F' }, params => true); + parser.registerCsiHandler({ final: 'G' }, params => true); + parser.registerCsiHandler({ final: 'H' }, params => true); + parser.registerCsiHandler({ final: 'I' }, params => true); + parser.registerCsiHandler({ final: 'J' }, params => true); + parser.registerCsiHandler({ final: 'K' }, params => true); + parser.registerCsiHandler({ final: 'L' }, params => true); + parser.registerCsiHandler({ final: 'M' }, params => true); + parser.registerCsiHandler({ final: 'P' }, params => true); + parser.registerCsiHandler({ final: 'S' }, params => true); + parser.registerCsiHandler({ final: 'T' }, params => true); + parser.registerCsiHandler({ final: 'X' }, params => true); + parser.registerCsiHandler({ final: 'Z' }, params => true); + parser.registerCsiHandler({ final: '`' }, params => true); + parser.registerCsiHandler({ final: 'a' }, params => true); + parser.registerCsiHandler({ final: 'b' }, params => true); + parser.registerCsiHandler({ final: 'c' }, params => true); + parser.registerCsiHandler({ final: 'd' }, params => true); + parser.registerCsiHandler({ final: 'e' }, params => true); + parser.registerCsiHandler({ final: 'f' }, params => true); + parser.registerCsiHandler({ final: 'g' }, params => true); + parser.registerCsiHandler({ final: 'h' }, params => true); + parser.registerCsiHandler({ final: 'l' }, params => true); + parser.registerCsiHandler({ final: 'm' }, params => true); + parser.registerCsiHandler({ final: 'n' }, params => true); + parser.registerCsiHandler({ final: 'p' }, params => true); + parser.registerCsiHandler({ final: 'q' }, params => true); + parser.registerCsiHandler({ final: 'r' }, params => true); + parser.registerCsiHandler({ final: 's' }, params => true); + parser.registerCsiHandler({ final: 'u' }, params => true); parser.setExecuteHandler(C0.BEL, () => true); parser.setExecuteHandler(C0.LF, () => true); parser.setExecuteHandler(C0.VT, () => true); @@ -90,24 +90,24 @@ perfContext('Parser throughput - 50MB data', () => { parser.setExecuteHandler(C1.HTS, () => true); parser.registerOscHandler(0, new OscHandler(data => true)); parser.registerOscHandler(1, new FastOscHandler()); - parser.registerEscHandler({final: '7'}, () => true); - parser.registerEscHandler({final: '8'}, () => true); - parser.registerEscHandler({final: 'D'}, () => true); - parser.registerEscHandler({final: 'E'}, () => true); - parser.registerEscHandler({final: 'H'}, () => true); - parser.registerEscHandler({final: 'M'}, () => true); - parser.registerEscHandler({final: '='}, () => true); - parser.registerEscHandler({final: '>'}, () => true); - parser.registerEscHandler({final: 'c'}, () => true); - parser.registerEscHandler({final: 'n'}, () => true); - parser.registerEscHandler({final: 'o'}, () => true); - parser.registerEscHandler({final: '|'}, () => true); - parser.registerEscHandler({final: '}'}, () => true); - parser.registerEscHandler({final: '~'}, () => true); - parser.registerEscHandler({intermediates: '%', final: '@'}, () => true); - parser.registerEscHandler({intermediates: '%', final: 'G'}, () => true); - parser.registerDcsHandler({final: 'p'}, new DcsHandler(data => true)); - parser.registerDcsHandler({final: 'q'}, new FastDcsHandler()); + parser.registerEscHandler({ final: '7' }, () => true); + parser.registerEscHandler({ final: '8' }, () => true); + parser.registerEscHandler({ final: 'D' }, () => true); + parser.registerEscHandler({ final: 'E' }, () => true); + parser.registerEscHandler({ final: 'H' }, () => true); + parser.registerEscHandler({ final: 'M' }, () => true); + parser.registerEscHandler({ final: '=' }, () => true); + parser.registerEscHandler({ final: '>' }, () => true); + parser.registerEscHandler({ final: 'c' }, () => true); + parser.registerEscHandler({ final: 'n' }, () => true); + parser.registerEscHandler({ final: 'o' }, () => true); + parser.registerEscHandler({ final: '|' }, () => true); + parser.registerEscHandler({ final: '}' }, () => true); + parser.registerEscHandler({ final: '~' }, () => true); + parser.registerEscHandler({ intermediates: '%', final: '@' }, () => true); + parser.registerEscHandler({ intermediates: '%', final: 'G' }, () => true); + parser.registerDcsHandler({ final: 'p' }, new DcsHandler(data => true)); + parser.registerDcsHandler({ final: 'q' }, new FastDcsHandler()); }); perfContext('PRINT - a', () => { @@ -121,8 +121,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', async () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('EXECUTE - \\n', () => { @@ -136,8 +136,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('ESCAPE - ESC E', () => { @@ -151,8 +151,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('ESCAPE with collect - ESC % G', () => { @@ -166,8 +166,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('CSI - CSI A', () => { @@ -181,8 +181,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('CSI with collect - CSI ? p', () => { @@ -196,8 +196,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('CSI with params (short) - CSI 1;2 m', () => { @@ -211,8 +211,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('CSI with params (long) - CSI 1;2;3;4;5;6;7;8;9;0 m', () => { @@ -226,8 +226,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('OSC string interface (short seq) - OSC 0;hi ST', () => { @@ -241,8 +241,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('OSC string interface (long seq) - OSC 0; ST', () => { @@ -256,8 +256,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('OSC class interface (short seq) - OSC 0;hi ST', () => { @@ -271,8 +271,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('OSC class interface (long seq) - OSC 0; ST', () => { @@ -286,8 +286,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('DCS string interface (short seq)', () => { @@ -301,8 +301,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', async () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('DCS string interface (long seq)', () => { @@ -316,8 +316,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', async () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('DCS class interface (short seq)', () => { @@ -331,8 +331,8 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', async () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); perfContext('DCS class interface (long seq)', () => { @@ -346,7 +346,7 @@ perfContext('Parser throughput - 50MB data', () => { }); new ThroughputRuntimeCase('', async () => { parser.parse(parsed, parsed.length); - return {payloadSize: parsed.length}; - }, {fork: true}).showAverageThroughput(); + return { payloadSize: parsed.length }; + }, { fork: true }).showAverageThroughput(); }); }); diff --git a/test/benchmark/Terminal.benchmark.ts b/test/benchmark/Terminal.benchmark.ts index 40a3c208f..578a83d03 100644 --- a/test/benchmark/Terminal.benchmark.ts +++ b/test/benchmark/Terminal.benchmark.ts @@ -47,22 +47,22 @@ perfContext('Terminal: ls -lR /usr/lib', () => { perfContext('write/string/async', () => { let terminal: Terminal; before(() => { - terminal = new Terminal({cols: 80, rows: 25, scrollback: 1000}); + terminal = new Terminal({ cols: 80, rows: 25, scrollback: 1000 }); }); new ThroughputRuntimeCase('', async () => { await new Promise(res => terminal.write(content, res)); - return {payloadSize: contentUtf8.length}; - }, {fork: false}).showAverageThroughput(); + return { payloadSize: contentUtf8.length }; + }, { fork: false }).showAverageThroughput(); }); perfContext('write/Utf8/async', () => { let terminal: Terminal; before(() => { - terminal = new Terminal({cols: 80, rows: 25, scrollback: 1000}); + terminal = new Terminal({ cols: 80, rows: 25, scrollback: 1000 }); }); new ThroughputRuntimeCase('', async () => { await new Promise(res => terminal.write(content, res)); - return {payloadSize: contentUtf8.length}; - }, {fork: false}).showAverageThroughput(); + return { payloadSize: contentUtf8.length }; + }, { fork: false }).showAverageThroughput(); }); }); From 6b7b279742fdd57d0d627c5038a3c2b2a5f006f0 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Fri, 13 Aug 2021 10:47:30 -0700 Subject: [PATCH 081/164] refactor --- src/browser/renderer/BoxAndBlockCharacters.ts | 414 ++++++++++-------- 1 file changed, 234 insertions(+), 180 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index b6ac8dc9d..a3d883516 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -243,6 +243,24 @@ const topYAxisFromMiddle = `${MOVE}${CENTER.TOP} ${TO}${CENTER.MIDDLE}`; const rightMiddleXAxis = `${MOVE}${CENTER.MIDDLE} ${TO}${RIGHT.MIDDLE}`; const leftMiddleXAxis = `${MOVE}${CENTER.MIDDLE} ${TO}${LEFT.MIDDLE}`; +const topXLine = `${MOVE}${'0,.45'} ${TO}${'1,.45'}`; +const bottomXLine = `${MOVE}${'0,.55'} ${TO}${'1,.55'}`; +const leftYLine = `${MOVE}${'.35,0'} ${TO}${'.35,1'}`; +const rightYLine = `${MOVE}${'.65,0'} ${TO}${'.65,1'}`; + +const leftTopXLine = `${MOVE}${'0,.45'} ${TO}${'.5,.45'}`; +const rightTopXLine = `${MOVE}${'.5,.45'} ${TO}${'1,.45'}`; + +const leftBottomXLine = `${MOVE}${'0,.55'} ${TO}${'.5,.55'}`; +const rightBottomXLine = `${MOVE}${'.5,.55'} ${TO}${'1,.55'}`; + +const bottomLeftYLine = `${MOVE}${'.35,.5'} ${TO}${'.35,1'}`; +const topLeftYLine = `${MOVE}${'.35,0'} ${TO}${'.35,.5'}`; + +const bottomRightYLine = `${MOVE}${'.65,.5'} ${TO}${'.65,1'}`; +const topRightYLine = `${MOVE}${'.65,0'} ${TO}${'.65,.5'}`; + + const map: { [character: string]: { [fontWeight: number]: string } } = { '━': { 1: `${xAxis}` @@ -368,178 +386,226 @@ const map: { [character: string]: { [fontWeight: number]: string } } = { }, '┫': { 2: `${yAxis} ${leftMiddleXAxis}` + }, + '┬': { + 1: `${bottomYAxisFromBottom} ${xAxis}` + }, + '┭': { + 1: `${bottomYAxisFromBottom} ${rightMiddleXAxis}`, + 2: `${leftMiddleXAxis}` + }, + '┮': { + 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}`, + 2: `${rightMiddleXAxis}` + }, + '┯': { + 1: `${bottomYAxisFromBottom}`, + 2: `${leftMiddleXAxis} ${rightMiddleXAxis}` + }, + '┰': { + 1: `${xAxis}`, + 2: `${bottomYAxisFromBottom}` + }, + '┱': { + 1: `${rightMiddleXAxis}`, + 2: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` + }, + '┲': { + 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}`, + 2: `${rightMiddleXAxis}` + }, + '┳': { + 2: `${bottomYAxisFromBottom} ${xAxis}` + }, + '┴': { + 1: `${topYAxisFromMiddle} ${xAxis}` + }, + '┵': { + 1: `${topYAxisFromMiddle} ${rightMiddleXAxis}`, + 2: `${leftMiddleXAxis}` + }, + '┶': { + 1: `${topYAxisFromMiddle} ${leftMiddleXAxis}`, + 2: `${rightMiddleXAxis}` + }, + '┷': { + 1: `${topYAxisFromMiddle}`, + 2: `${leftMiddleXAxis} ${rightMiddleXAxis}` + }, + '┸': { + 1: `${xAxis}`, + 2: `${topYAxisFromMiddle}` + }, + '┹': { + 1: `${rightMiddleXAxis}`, + 2: `${topYAxisFromMiddle} ${leftMiddleXAxis}` + }, + '┺': { + 1: `${topYAxisFromMiddle} ${leftMiddleXAxis}`, + 2: `${rightMiddleXAxis}` + }, + '┻': { + 2: `${topYAxisFromMiddle} ${xAxis}` + }, + '┼': { + 1: `${yAxis} ${xAxis}` + }, + '┽': { + 1: `${yAxis} ${rightMiddleXAxis}`, + 2: `${leftMiddleXAxis}` + }, + '┾': { + 1: `${yAxis} ${leftMiddleXAxis}`, + 2: `${rightMiddleXAxis}` + }, + '┿': { + 1: `${yAxis}`, + 2: `${leftMiddleXAxis} ${rightMiddleXAxis}` + }, + '╀': { + 1: `${xAxis}`, + 2: `${yAxis}` + }, + '╁': { + 1: `${rightMiddleXAxis}`, + 2: `${yAxis} ${leftMiddleXAxis}` + }, + '╂': { + 1: `${yAxis} ${leftMiddleXAxis}`, + 2: `${rightMiddleXAxis}` + }, + '╃': { + 1: `${bottomYAxisFromBottom} ${rightMiddleXAxis}`, + 2: `${topYAxisFromTop} ${leftMiddleXAxis}` + }, + '╄': { + 1: `${topYAxisFromTop} ${leftMiddleXAxis}`, + 2: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` + }, + '╅': { + 1: `${topYAxisFromTop} ${rightMiddleXAxis}`, + 2: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` + }, + '╆': { + 1: `${topYAxisFromTop} ${leftMiddleXAxis}`, + 2: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` + }, + '╇': { + 1: `${bottomYAxisFromBottom}`, + 2: `${leftMiddleXAxis} ${topYAxisFromTop} ${rightMiddleXAxis}` + }, + '╈': { + 1: `${topYAxisFromTop}`, + 2: `${leftMiddleXAxis} ${bottomYAxisFromBottom} ${rightMiddleXAxis}` + }, + '╉': { + 1: `${rightMiddleXAxis}`, + 2: `${leftMiddleXAxis} ${yAxis}` + }, + '╊': { + 1: `${leftMiddleXAxis}`, + 2: `${rightMiddleXAxis} ${yAxis}` + }, + '╋': { + 2: `${yAxis} ${xAxis}` + }, + '╌': { + 1: `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}` + }, + '╍': { + 2: `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}` + }, + '╎': { + 1: `${MOVE}${CENTER.TOP} ${TO}${'.5,.45'} ${MOVE}${'.5,.55'} ${TO}${CENTER.BOTTOM}` + }, + '╏': { + 2: `${MOVE}${CENTER.TOP} ${TO}${'.5,.45'} ${MOVE}${'.5,.55'} ${TO}${CENTER.BOTTOM}` + }, + '═': { + 1: `${MOVE}${'0,.45'} ${TO}${'1,.45'} ${MOVE}${'0,.55'} ${TO}${'1,.55'}` + }, + '║': { + 1: `${MOVE}${'.35,0'} ${TO}${'.35,1'} ${MOVE}${'.65,0'} ${TO}${'.65,1'}` + }, + '╒': { + 1: `${rightTopXLine} ${rightBottomXLine} ${MOVE}${'.55,1'} ${TO}${'.55,.45'}` + }, + '╓': { + 1: `${bottomLeftYLine} ${bottomRightYLine} ${MOVE}${'.3,.5'} ${TO}${'1,.5'}` + }, + '╔': { + 1: `${MOVE}${'.35,.45'} ${TO}${'1,.45'} ${MOVE}${'.35,.45'} ${TO}${'.35,1'} ${MOVE}${'.65,.65'} ${TO}${'1,.65'} ${MOVE}${'.65,.625'} ${TO}${'.65,1'}` + }, + '╕': { + 1: `${leftTopXLine} ${leftBottomXLine} ${MOVE}${'.55,1'} ${TO}${'.55,.45'}` + }, + '╖': { + 1: `${bottomLeftYLine} ${bottomRightYLine} ${MOVE}${'0,.5'} ${TO}${'.7,.5'}` + }, + '╗': { + 1: `${MOVE}${'.35,.45'} ${TO}${'1,.45'} ${MOVE}${'1,.45'} ${TO}${'1,1'} ${MOVE}${'.35,.65'} ${TO}${'.7,.65'} ${MOVE}${'.7,.65'} ${TO}${'.7,1'}` + }, + '╘': { + 1: `${MOVE}${'0,.85'} ${TO}${'.5,.85'} ${MOVE}${'0,1'} ${TO}${'.5,1'} ${MOVE}${'0,.5'} ${TO}${'0,1'}` + }, + '╙': { + 1: `${MOVE}${'0,.5'} ${TO}${'0,1'} ${MOVE}${'.35,.5'} ${TO}${'.35,1'} ${MOVE}${'0,1'} ${TO}${'.7,1'}` + }, + '╚': { + 1: `${MOVE}${'0,.5'} ${TO}${'0,1'} ${MOVE}${'.35,.5'} ${TO}${'.35,.85'} ${MOVE}${'0,1'} ${TO}${'.7,1'} ${MOVE}${'.5,.85'} ${TO}${'1,.85'}` + }, + '╛': { + 1: `${MOVE}${'0,.85'} ${TO}${'.5,.85'} ${MOVE}${'0,1'} ${TO}${'.5,1'} ${MOVE}${'.55,1'} ${TO}${'.55,.45'}` + }, + '╜': { + 1: `${bottomLeftYLine} ${bottomRightYLine} ${MOVE}${'0,1'} ${TO}${'.7,1'}` + }, + '╝': { + 1: `${MOVE}${'.35,.45'} ${TO}${'.35,.85'} ${MOVE}${'.65,.45'} ${TO} ${'.65,1'} ${MOVE}${'0,.85'} ${TO}${'.45,.85'} ${MOVE}${'0,1'} ${TO}${'.65,1'}` + }, + '╴': { + 1: `${leftMiddleXAxis}` + }, + '╵': { + 1: `${topYAxisFromMiddle}` + }, + '╶': { + 1: `${rightMiddleXAxis}` + }, + '╷': { + 1: `${bottomYAxisFromMiddle}` + }, + '╸': { + 2: `${leftMiddleXAxis}` + }, + '╹': { + 2: `${topYAxisFromMiddle}` + }, + '╺': { + 2: `${rightMiddleXAxis}` + }, + '╻': { + 2: `${bottomYAxisFromMiddle}` + }, + '╼': { + 1: `${leftMiddleXAxis}`, + 2: `${rightMiddleXAxis}` + }, + '╽': { + 1: `${topYAxisFromMiddle}`, + 2: `${bottomYAxisFromBottom}` + }, + '╾': { + 1: `${rightMiddleXAxis}`, + 2: `${leftMiddleXAxis}` + }, + '╿': { + 1: `${bottomYAxisFromBottom}`, + 2: `${topYAxisFromMiddle}` } }; const chars: { [index: string]: string } = { - // '┬': { - // 1: `${bottomYAxisFromBottom} ${xAxis}`, - // 1: `${bottomYAxisFromBottom} ${xAxis}`, - // } - // '┭': { - // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // } - // '┮': { - // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // } - // '┯': { - // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - // } - // '┰': { - // 1: `${bottomYAxisFromBottom}${THICK} ${xAxis}`, - // 1: `${bottomYAxisFromBottom}${THICK} ${xAxis}`, - // } - // '┱': { - // 1: `${bottomYAxisFromBottom}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // 1: `${bottomYAxisFromBottom}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // } - // '┲': { - // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // } - // '┳': { - // 1: `${bottomYAxisFromBottom}${THICK} ${xAxis}${THICK}`, - // 1: `${bottomYAxisFromBottom}${THICK} ${xAxis}${THICK}`, - // } - // '┴': { - // 1: `${topYAxisFromTop} ${xAxis}`, - // 1: `${topYAxisFromTop} ${xAxis}`, - // } - // '┵': { - // 1: `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // 1: `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // } - // '┶': { - // 1: `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // 1: `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // } - // '┷': { - // 1: `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - // 1: `${topYAxisFromTop} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - // } - // '┸': { - // 1: `${topYAxisFromTop}${THICK} ${xAxis}`, - // 1: `${topYAxisFromTop}${THICK} ${xAxis}`, - // } - // '┹': { - // 1: `${topYAxisFromTop}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // 1: `${topYAxisFromTop}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // } - // '┺': { - // 1: `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // 1: `${topYAxisFromTop} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // } - // '┻': { - // 1: `${topYAxisFromTop}${THICK} ${xAxis}${THICK}`, - // 1: `${topYAxisFromTop}${THICK} ${xAxis}${THICK}`, - // } - // '┼': { - // 1: `${yAxis} ${xAxis}`, - // 1: `${yAxis} ${xAxis}`, - // } - // '┽': { - // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // } - // '┾': { - // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // } - // '┿': { - // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - // } - // '╀': { - // 1: `${yAxis}${THICK} ${xAxis}`, - // 1: `${yAxis}${THICK} ${xAxis}`, - // } - // '╁': { - // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // } - // '╂': { - // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // } - // '╃': { - // 1: `${yAxis}${THICK} ${xAxis}${THICK}`, - // 1: `${yAxis}${THICK} ${xAxis}${THICK}`, - // } - // '╄': { - // 1: `${yAxis} ${xAxis}`, - // 1: `${yAxis} ${xAxis}`, - // } - // '╅': { - // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // } - // '╆': { - // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // } - // '╇': { - // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - // 1: `${yAxis} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}${THICK}`, - // } - // '╈': { - // 1: `${yAxis}${THICK} ${xAxis}`, - // 1: `${yAxis}${THICK} ${xAxis}`, - // } - // '╉': { - // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // 1: `${yAxis}${THICK} ${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, - // } - // '╊': { - // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // 1: `${yAxis} ${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, - // } - // '╋': { - // 1: `${yAxis}${THICK} ${xAxis}${THICK}`, - // 1: `${yAxis}${THICK} ${xAxis}${THICK}`, - // } - // '╌': { - // 1: `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}`, - // 1: `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}`, - // } - // '╍': { - // 1: `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'}${THICK} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}${THICK}`, - // 1: `${MOVE}${LEFT.MIDDLE} ${TO}${'.47,.5'}${THICK} ${MOVE}${'.53,.5'} ${TO}${RIGHT.MIDDLE}${THICK}`, - // } - // '╎':`{ - // 1: ${MOVE}${CENTER.TOP} ${TO}${'.5,.47'} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}` - // 1: ${MOVE}${CENTER.TOP} ${TO}${'.5,.47'} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}` - // }, - // '╏':`{ - // 1: ${MOVE}${CENTER.TOP} ${TO}${'.5,.47'}${THICK} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}${THICK}` - // 1: ${MOVE}${CENTER.TOP} ${TO}${'.5,.47'}${THICK} ${MOVE}${'.5,.53'} ${TO}${CENTER.BOTTOM}${THICK}` - // }, - // // '═{ - // 1: ': `${MOVE}${} ${TO}${} ${TO}${ - // 1: ': `${MOVE}${} ${TO}${} ${TO}${ - - // }`, - - // } // '║{ - // 1: ': `${MOVE}${} ${TO}${} ${TO}${ - // 1: ': `${MOVE}${} ${TO}${} ${TO}${ - - // }`, - -// } // '╒': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╓': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╔': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╕': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╖': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╗': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╘': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╙': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╚': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╛': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╜': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╝': `${MOVE}${} ${TO}${} ${TO}${}`, // // '╞': `${MOVE}${} ${TO}${} ${TO}${}`, // // '╟': `${MOVE}${} ${TO}${} ${TO}${}`, // // '╠': `${MOVE}${} ${TO}${} ${TO}${}`, @@ -562,18 +628,6 @@ const chars: { [index: string]: string } = { // // '╱': `${MOVE}${} ${TO}${} ${TO}${}`, // // '╲': `${MOVE}${} ${TO}${} ${TO}${}`, // // '╳': `${MOVE}${} ${TO}${} ${TO}${}`, -// '╴': `${leftMiddleXAxis}`, -// '╵': `${topYAxisFromMiddle}`, -// '╶': `${rightMiddleXAxis}`, -// '╷': `${bottomYAxisFromMiddle}`, -// '╸': `${leftMiddleXAxis}${THICK}`, -// '╹': `${topYAxisFromMiddle}${THICK}`, -// '╺': `${rightMiddleXAxis}${THICK}`, -// '╻': `${bottomYAxisFromMiddle}${THICK}`, -// '╼': `${leftMiddleXAxis} ${rightMiddleXAxis}${THICK}`, -// '╽': `${bottomYAxisFromBottom}${THICK} ${topYAxisFromMiddle}`, -// '╾': `${leftMiddleXAxis}${THICK} ${rightMiddleXAxis}`, -// '╿': `${bottomYAxisFromBottom} ${topYAxisFromMiddle}${THICK}` }; export function draw(ctx: CanvasRenderingContext2D, c: string, xOffset: number, yOffset: number, cellWidth: number, cellHeight: number): void { From 263e5b95cf177c78acc09fa4fbe449102b2e806a Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 13 Aug 2021 12:52:50 -0700 Subject: [PATCH 082/164] Improve testing characters and use fake terminal for demo --- demo/client.ts | 53 +++++++++++++++++++++++++++----------- src/common/CoreTerminal.ts | 26 ------------------- 2 files changed, 38 insertions(+), 41 deletions(-) diff --git a/demo/client.ts b/demo/client.ts index 0bb124cd4..d7c0f8404 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -214,16 +214,17 @@ function createTerminal(): void { // Set terminal size again to set the specific dimensions on the demo updateTerminalSize(); - fetch('/terminals?cols=' + term.cols + '&rows=' + term.rows, {method: 'POST'}).then((res) => { - res.text().then((processId) => { - pid = processId; - socketURL += processId; - socket = new WebSocket(socketURL); - socket.onopen = runRealTerminal; - socket.onclose = runFakeTerminal; - socket.onerror = runFakeTerminal; - }); - }); + // fetch('/terminals?cols=' + term.cols + '&rows=' + term.rows, {method: 'POST'}).then((res) => { + // res.text().then((processId) => { + // pid = processId; + // socketURL += processId; + // socket = new WebSocket(socketURL); + // socket.onopen = runRealTerminal; + // socket.onclose = runFakeTerminal; + // socket.onerror = runFakeTerminal; + // }); + // }); + runFakeTerminal(); }, 0); } @@ -246,11 +247,33 @@ function runFakeTerminal(): void { term.write('\r\n$ '); }; - term.writeln('Welcome to xterm.js'); - term.writeln('This is a local terminal emulation, without a real terminal in the back-end.'); - term.writeln('Type some keys and commands to play around.'); - term.writeln(''); - term.prompt(); + // term.writeln('Welcome to xterm.js'); + // term.writeln('This is a local terminal emulation, without a real terminal in the back-end.'); + // term.writeln('Type some keys and commands to play around.'); + // term.writeln(''); + // term.prompt(); + + term.write('Box styles: ┎┰┒┍┯┑╓╥╖╒╤╕ ┏┳┓┌┲┓┌┬┐┏┱┐\n\r'); + term.write('┌─┬─┐ ┏━┳━┓ ╔═╦═╗ ┠╂┨┝┿┥╟╫╢╞╪╡ ┡╇┩├╊┫┢╈┪┣╉┤\n\r'); + term.write('│ │ │ ┃ ┃ ┃ ║ ║ ║ ┖┸┚┕┷┙╙╨╜╘╧╛ └┴┘└┺┛┗┻┛┗┹┘\n\r'); + term.write('├─┼─┤ ┣━╋━┫ ╠═╬═╣ ┏┱┐┌┲┓┌┬┐┌┬┐ ┏┳┓┌┮┓┌┬┐┏┭┐\n\r'); + term.write('│ │ │ ┃ ┃ ┃ ║ ║ ║ ┡╃┤├╄┩├╆┪┢╅┤ ┞╀┦├┾┫┟╁┧┣┽┤\n\r'); + term.write('└─┴─┘ ┗━┻━┛ ╚═╩═╝ └┴┘└┴┘└┺┛┗┹┘ └┴┘└┶┛┗┻┛┗┵┘\n\r'); + term.write('\n\r'); + term.write('Other:\n\r'); + term.write('╭─╮ ╲ ╱ ╷╻╎╏┆┇┊┋ ╺╾╴ ╌╌ ┄┄ ┈┈\n\r'); + term.write('│ │ ╳ ╽╿╎╏┆┇┊┋ ╶╼╸ ╍╍ ┅┅ ┉┉\n\r'); + term.write('╰─╯ ╱ ╲ ╹╵╎╏┆┇┊┋\n\r'); + term.write('\n\r'); + term.write('All box drawing characters:\n\r'); + term.write('─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏\n\r'); + term.write('┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟\n\r'); + term.write('┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯\n\r'); + term.write('┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿\n\r'); + term.write('╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╌ ╍ ╎ ╏\n\r'); + term.write('═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟\n\r'); + term.write('╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯\n\r'); + term.write('╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\n\r'); term.onKey((e: { key: string, domEvent: KeyboardEvent }) => { const ev = e.domEvent; diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index a3026016a..e61a8e16e 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -132,32 +132,6 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { // Setup WriteBuffer this._writeBuffer = new WriteBuffer((data, promiseResult) => this._inputHandler.parse(data, promiseResult)); - setTimeout(() => { - // this.write('─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏\r\n'); - // this.write('┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟\r\n'); - // this.write('┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯\r\n'); - // this.write('┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿\r\n'); - // this.write('╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╌ ╍ ╎ ╏\r\n'); - // this.write('═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟\r\n'); - // this.write('╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯\r\n'); - // this.write('╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\r\n'); - // this.write(' ╔═════════════════════════════════════════════════════════╕\r\n'); - // this.write(' ║ │\r\n'); - // this.write(' ║ ╔═══════════════╦════════╤════════╗ │\r\n'); - // this.write(' ║ ║ ║ │ ║ │\r\n'); - // this.write(' ║ ║ ║ │ ║ │\r\n'); - // this.write('▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇'); - this.write('━━│┃\r\n'); - this.write(' ━━│┃┌┍┎┏\r\n'); - this.write(' ━━│┃┌┐┍┑┎┒┏┓\r\n'); - this.write(' └┘┕┙┖┚┗┛\r\n'); - this.write('├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿╀╁╂╃╄╅╆╇╈╉╊╋ ╌ ╍╎╏═║╒╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡╢╣╤╥╦╧╨╩╪╫╬\r\n'); - this.write('╭╮╯╰╱╲╳╴╵╶╷╸╹╺╻╼╽╾╿\r\n'); - this.write('├ ┝ ┞ ┟ ┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯ ┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻\r\n'); - this.write('┼ ┽ ┾ ┿ ╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋\r\n'); - this.write(' ╌ ╍ ╎ ╏ ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬\r\n'); - this.write('╭ ╮ ╯ ╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\r\n'); - }, 1000); } public dispose(): void { From f83ebdbe67fcdf6631322485a57d9c689dadb146 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 13 Aug 2021 14:53:45 -0700 Subject: [PATCH 083/164] Refactors and implementing new shapes Co-authored-by: Megan Rogge --- src/browser/renderer/BoxAndBlockCharacters.ts | 525 ++++++------------ 1 file changed, 179 insertions(+), 346 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index a3d883516..c220c9aa6 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -260,349 +260,170 @@ const topLeftYLine = `${MOVE}${'.35,0'} ${TO}${'.35,.5'}`; const bottomRightYLine = `${MOVE}${'.65,.5'} ${TO}${'.65,1'}`; const topRightYLine = `${MOVE}${'.65,0'} ${TO}${'.65,.5'}`; +const enum Shapes { + /** │ */ TOP_TO_BOTTOM = 'M.5,0 L.5,1', + /** ─ */ LEFT_TO_RIGHT = 'M0,.5 L1,.5', -const map: { [character: string]: { [fontWeight: number]: string } } = { - '━': { - 1: `${xAxis}` - }, - '│': { - 1: `${yAxis}` - }, - '┃': { - 2: `${yAxis}` - }, - '┌': { - 1: `${bottomYAxisFromBottom} ${TO}${RIGHT.MIDDLE}` - }, - '┍': { - 1: `${bottomYAxisFromBottom}`, - 2: `${rightMiddleXAxis}` - }, - '┎': { - 1: `${rightMiddleXAxis}`, - 2: `${bottomYAxisFromBottom}` - }, - '┏': { - 2: `${bottomYAxisFromBottom} ${TO}${RIGHT.MIDDLE}` - }, - '┐': { - 1: `${bottomYAxisFromBottom} ${TO}${LEFT.MIDDLE}` - }, - '┑': { - 1: `${bottomYAxisFromBottom}`, - 2: `${leftMiddleXAxis}` - }, - '┒': { - 1: `${leftMiddleXAxis}`, - 2: `${bottomYAxisFromBottom}` - }, - '┓': { - 2: `${bottomYAxisFromBottom} ${TO}${LEFT.MIDDLE}` - }, - '└': { - 1: `${topYAxisFromTop} ${TO}${RIGHT.MIDDLE}` - }, - '┕': { - 1: `${topYAxisFromTop}`, - 2: `${rightMiddleXAxis}` - }, - '┖': { - 1: `${rightMiddleXAxis}`, - 2: `${topYAxisFromTop}` - }, - '┗': { - 2: `${topYAxisFromTop} ${TO}${RIGHT.MIDDLE}` - }, - '┘': { - 1: `${topYAxisFromTop} ${TO}${LEFT.MIDDLE}` - }, - '┙': { - 1: `${topYAxisFromTop}`, - 2: `${leftMiddleXAxis}` - }, - '┚': { - 1: `${leftMiddleXAxis}`, - 2: `${topYAxisFromTop}` - }, - '┛': { - 2: `${topYAxisFromTop} ${TO}${LEFT.MIDDLE}` - }, - '├': { - 1: `${yAxis} ${rightMiddleXAxis}` - }, - '┝': { - 1: `${yAxis}`, - 2: `${rightMiddleXAxis}` - }, - '┞': { - 1: `${bottomYAxisFromMiddle} ${rightMiddleXAxis}`, - 2: `${topYAxisFromTop}` - }, - '┟': { - 1: `${topYAxisFromMiddle} ${rightMiddleXAxis}`, - 2: `${bottomYAxisFromBottom}` - }, - '┠': { - 1: `${rightMiddleXAxis}`, - 2: `${yAxis}` - }, - '┡': { - 1: `${bottomYAxisFromBottom}`, - 2: `${topYAxisFromMiddle} ${rightMiddleXAxis}` - }, - '┢': { - 1: `${topYAxisFromMiddle}`, - 2: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` - }, - '┣': { - 2: `${yAxis} ${rightMiddleXAxis}` - }, - '┤': { - 1: `${yAxis} ${leftMiddleXAxis}` - }, - '┥': { - 1: `${yAxis}`, - 2: `${leftMiddleXAxis}` - }, - '┦': { - 1: `${bottomYAxisFromMiddle} ${leftMiddleXAxis}`, - 2: `${topYAxisFromTop}` - }, - '┧': { - 1: `${topYAxisFromMiddle}`, - 2: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` - }, - '┨': { - 1: `${leftMiddleXAxis}`, - 2: `${yAxis}` - }, - '┩': { - 2: `${topYAxisFromMiddle} ${leftMiddleXAxis}`, - 1: `${bottomYAxisFromMiddle}` - }, - '┪': { - 1: `${topYAxisFromMiddle}`, - 2: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` - }, - '┫': { - 2: `${yAxis} ${leftMiddleXAxis}` - }, - '┬': { - 1: `${bottomYAxisFromBottom} ${xAxis}` - }, - '┭': { - 1: `${bottomYAxisFromBottom} ${rightMiddleXAxis}`, - 2: `${leftMiddleXAxis}` - }, - '┮': { - 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}`, - 2: `${rightMiddleXAxis}` - }, - '┯': { - 1: `${bottomYAxisFromBottom}`, - 2: `${leftMiddleXAxis} ${rightMiddleXAxis}` - }, - '┰': { - 1: `${xAxis}`, - 2: `${bottomYAxisFromBottom}` - }, - '┱': { - 1: `${rightMiddleXAxis}`, - 2: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` - }, - '┲': { - 1: `${bottomYAxisFromBottom} ${leftMiddleXAxis}`, - 2: `${rightMiddleXAxis}` - }, - '┳': { - 2: `${bottomYAxisFromBottom} ${xAxis}` - }, - '┴': { - 1: `${topYAxisFromMiddle} ${xAxis}` - }, - '┵': { - 1: `${topYAxisFromMiddle} ${rightMiddleXAxis}`, - 2: `${leftMiddleXAxis}` - }, - '┶': { - 1: `${topYAxisFromMiddle} ${leftMiddleXAxis}`, - 2: `${rightMiddleXAxis}` - }, - '┷': { - 1: `${topYAxisFromMiddle}`, - 2: `${leftMiddleXAxis} ${rightMiddleXAxis}` - }, - '┸': { - 1: `${xAxis}`, - 2: `${topYAxisFromMiddle}` - }, - '┹': { - 1: `${rightMiddleXAxis}`, - 2: `${topYAxisFromMiddle} ${leftMiddleXAxis}` - }, - '┺': { - 1: `${topYAxisFromMiddle} ${leftMiddleXAxis}`, - 2: `${rightMiddleXAxis}` - }, - '┻': { - 2: `${topYAxisFromMiddle} ${xAxis}` - }, - '┼': { - 1: `${yAxis} ${xAxis}` - }, - '┽': { - 1: `${yAxis} ${rightMiddleXAxis}`, - 2: `${leftMiddleXAxis}` - }, - '┾': { - 1: `${yAxis} ${leftMiddleXAxis}`, - 2: `${rightMiddleXAxis}` - }, - '┿': { - 1: `${yAxis}`, - 2: `${leftMiddleXAxis} ${rightMiddleXAxis}` - }, - '╀': { - 1: `${xAxis}`, - 2: `${yAxis}` - }, - '╁': { - 1: `${rightMiddleXAxis}`, - 2: `${yAxis} ${leftMiddleXAxis}` - }, - '╂': { - 1: `${yAxis} ${leftMiddleXAxis}`, - 2: `${rightMiddleXAxis}` - }, - '╃': { - 1: `${bottomYAxisFromBottom} ${rightMiddleXAxis}`, - 2: `${topYAxisFromTop} ${leftMiddleXAxis}` - }, - '╄': { - 1: `${topYAxisFromTop} ${leftMiddleXAxis}`, - 2: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` - }, - '╅': { - 1: `${topYAxisFromTop} ${rightMiddleXAxis}`, - 2: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` - }, - '╆': { - 1: `${topYAxisFromTop} ${leftMiddleXAxis}`, - 2: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` - }, - '╇': { - 1: `${bottomYAxisFromBottom}`, - 2: `${leftMiddleXAxis} ${topYAxisFromTop} ${rightMiddleXAxis}` - }, - '╈': { - 1: `${topYAxisFromTop}`, - 2: `${leftMiddleXAxis} ${bottomYAxisFromBottom} ${rightMiddleXAxis}` - }, - '╉': { - 1: `${rightMiddleXAxis}`, - 2: `${leftMiddleXAxis} ${yAxis}` - }, - '╊': { - 1: `${leftMiddleXAxis}`, - 2: `${rightMiddleXAxis} ${yAxis}` - }, - '╋': { - 2: `${yAxis} ${xAxis}` - }, - '╌': { - 1: `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}` - }, - '╍': { - 2: `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}` - }, - '╎': { - 1: `${MOVE}${CENTER.TOP} ${TO}${'.5,.45'} ${MOVE}${'.5,.55'} ${TO}${CENTER.BOTTOM}` - }, - '╏': { - 2: `${MOVE}${CENTER.TOP} ${TO}${'.5,.45'} ${MOVE}${'.5,.55'} ${TO}${CENTER.BOTTOM}` - }, - '═': { - 1: `${MOVE}${'0,.45'} ${TO}${'1,.45'} ${MOVE}${'0,.55'} ${TO}${'1,.55'}` - }, - '║': { - 1: `${MOVE}${'.35,0'} ${TO}${'.35,1'} ${MOVE}${'.65,0'} ${TO}${'.65,1'}` - }, - '╒': { - 1: `${rightTopXLine} ${rightBottomXLine} ${MOVE}${'.55,1'} ${TO}${'.55,.45'}` - }, - '╓': { - 1: `${bottomLeftYLine} ${bottomRightYLine} ${MOVE}${'.3,.5'} ${TO}${'1,.5'}` - }, - '╔': { - 1: `${MOVE}${'.35,.45'} ${TO}${'1,.45'} ${MOVE}${'.35,.45'} ${TO}${'.35,1'} ${MOVE}${'.65,.65'} ${TO}${'1,.65'} ${MOVE}${'.65,.625'} ${TO}${'.65,1'}` - }, - '╕': { - 1: `${leftTopXLine} ${leftBottomXLine} ${MOVE}${'.55,1'} ${TO}${'.55,.45'}` - }, - '╖': { - 1: `${bottomLeftYLine} ${bottomRightYLine} ${MOVE}${'0,.5'} ${TO}${'.7,.5'}` - }, - '╗': { - 1: `${MOVE}${'.35,.45'} ${TO}${'1,.45'} ${MOVE}${'1,.45'} ${TO}${'1,1'} ${MOVE}${'.35,.65'} ${TO}${'.7,.65'} ${MOVE}${'.7,.65'} ${TO}${'.7,1'}` - }, - '╘': { - 1: `${MOVE}${'0,.85'} ${TO}${'.5,.85'} ${MOVE}${'0,1'} ${TO}${'.5,1'} ${MOVE}${'0,.5'} ${TO}${'0,1'}` - }, - '╙': { - 1: `${MOVE}${'0,.5'} ${TO}${'0,1'} ${MOVE}${'.35,.5'} ${TO}${'.35,1'} ${MOVE}${'0,1'} ${TO}${'.7,1'}` - }, - '╚': { - 1: `${MOVE}${'0,.5'} ${TO}${'0,1'} ${MOVE}${'.35,.5'} ${TO}${'.35,.85'} ${MOVE}${'0,1'} ${TO}${'.7,1'} ${MOVE}${'.5,.85'} ${TO}${'1,.85'}` - }, - '╛': { - 1: `${MOVE}${'0,.85'} ${TO}${'.5,.85'} ${MOVE}${'0,1'} ${TO}${'.5,1'} ${MOVE}${'.55,1'} ${TO}${'.55,.45'}` - }, - '╜': { - 1: `${bottomLeftYLine} ${bottomRightYLine} ${MOVE}${'0,1'} ${TO}${'.7,1'}` - }, - '╝': { - 1: `${MOVE}${'.35,.45'} ${TO}${'.35,.85'} ${MOVE}${'.65,.45'} ${TO} ${'.65,1'} ${MOVE}${'0,.85'} ${TO}${'.45,.85'} ${MOVE}${'0,1'} ${TO}${'.65,1'}` - }, - '╴': { - 1: `${leftMiddleXAxis}` - }, - '╵': { - 1: `${topYAxisFromMiddle}` - }, - '╶': { - 1: `${rightMiddleXAxis}` - }, - '╷': { - 1: `${bottomYAxisFromMiddle}` - }, - '╸': { - 2: `${leftMiddleXAxis}` - }, - '╹': { - 2: `${topYAxisFromMiddle}` - }, - '╺': { - 2: `${rightMiddleXAxis}` - }, - '╻': { - 2: `${bottomYAxisFromMiddle}` - }, - '╼': { - 1: `${leftMiddleXAxis}`, - 2: `${rightMiddleXAxis}` - }, - '╽': { - 1: `${topYAxisFromMiddle}`, - 2: `${bottomYAxisFromBottom}` - }, - '╾': { - 1: `${rightMiddleXAxis}`, - 2: `${leftMiddleXAxis}` - }, - '╿': { - 1: `${bottomYAxisFromBottom}`, - 2: `${topYAxisFromMiddle}` - } + /** └ */ TOP_TO_RIGHT = 'M.5,0 L.5,.5 L1,.5', + /** ┘ */ TOP_TO_LEFT = 'M.5,0 L.5,.5 L0,.5', + /** ┐ */ LEFT_TO_BOTTOM = 'M0,.5 L.5,.5 L.5,1', + /** ┌ */ RIGHT_TO_BOTTOM = 'M0.5,1 L.5,.5 L1,.5', + + /** ╵ */ MIDDLE_TO_TOP = 'M.5,.5 L0,.5', + /** ╴ */ MIDDLE_TO_LEFT = 'M.5,.5 L.5,0', + /** ╶ */ MIDDLE_TO_RIGHT = 'M.5,.5 L1,.5', + /** ╷ */ MIDDLE_TO_BOTTOM = 'M.5,.5 L.5,1', + + /** ┴ */ T_TOP = 'M0,.5 L1,.5 M.5,.5 L.5,0', + /** ┤ */ T_LEFT = 'M.5,0 L.5,1 M.5,.5 L0,.5', + /** ├ */ T_RIGHT = 'M.5,0 L.5,1 M.5,.5 L1,.5', + /** ┬ */ T_BOTTOM = 'M0,.5 L1,.5 M.5,.5 L.5,1', + + /** ┼ */ CROSS = 'M0,.5 L1,.5 M.5,0 L.5,1', +} + +const enum Style { + NORMAL = 1, + BOLD = 2 +} + +// TODO: Tweak normal and bold weights +const map: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } } = { + // Uniform normal and bold + '─': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT }, + '━': { [Style.BOLD]: Shapes.LEFT_TO_RIGHT }, + '│': { [Style.NORMAL]: Shapes.TOP_TO_BOTTOM }, + '┃': { [Style.BOLD]: Shapes.TOP_TO_BOTTOM }, + '┌': { [Style.NORMAL]: Shapes.RIGHT_TO_BOTTOM }, + '┏': { [Style.BOLD]: Shapes.RIGHT_TO_BOTTOM }, + '┐': { [Style.NORMAL]: Shapes.LEFT_TO_BOTTOM }, + '┓': { [Style.BOLD]: Shapes.LEFT_TO_BOTTOM }, + '└': { [Style.NORMAL]: Shapes.TOP_TO_RIGHT }, + '┗': { [Style.BOLD]: Shapes.TOP_TO_RIGHT }, + '┘': { [Style.NORMAL]: Shapes.TOP_TO_LEFT }, + '┛': { [Style.BOLD]: Shapes.TOP_TO_LEFT }, + '├': { [Style.NORMAL]: Shapes.T_RIGHT }, + '┣': { [Style.BOLD]: Shapes.T_RIGHT }, + '┤': { [Style.NORMAL]: Shapes.T_LEFT }, + '┫': { [Style.BOLD]: Shapes.T_LEFT }, + '┬': { [Style.NORMAL]: Shapes.T_BOTTOM }, + '┳': { [Style.BOLD]: Shapes.T_BOTTOM }, + '┴': { [Style.NORMAL]: Shapes.T_TOP }, + '┻': { [Style.BOLD]: Shapes.T_TOP }, + '┼': { [Style.NORMAL]: Shapes.CROSS }, + '╋': { [Style.BOLD]: Shapes.CROSS }, + '╴': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT }, + '╸': { [Style.BOLD]: Shapes.MIDDLE_TO_LEFT }, + '╵': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP }, + '╹': { [Style.BOLD]: Shapes.MIDDLE_TO_TOP }, + '╶': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT }, + '╺': { [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT }, + '╷': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM }, + '╻': { [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, + + // Mixed normal/bold + '┍': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT }, + '┎': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, + + // Double border + '═': { [Style.NORMAL]: (xp, yp) => `M0,${.5 - yp} L1,${.5 - yp} M0,${.5 + yp} L1,${.5 + yp}` }, + '║': { [Style.NORMAL]: (xp, yp) => `M${.5 - xp},0 L${.5 - xp},1 M${.5 + xp},0 L${.5 + xp},1` }, + '╒': { [Style.NORMAL]: (xp, yp) => `M.5,1 L.5,${.5 - yp} L1,${.5 - yp} M.5,${.5 + yp} L1,${.5 + yp}` }, + '╓': { [Style.NORMAL]: (xp, yp) => `M${.5 - xp},1 L${.5 - xp},.5 L1,.5 M${.5 + xp},.5 L${.5 + xp},1` }, + '╔': { [Style.NORMAL]: (xp, yp) => `M1,${.5 - yp} L${.5 - xp},${.5 - yp} L${.5 - xp},1 M1,${.5 + yp} L${.5 + xp},${.5 + yp} L${.5 + xp},1` }, + '╕': { [Style.NORMAL]: (xp, yp) => `M0,${.5 - yp} L.5,${.5 - yp} L.5,1 M0,${.5 + yp} L.5,${.5 + yp}` }, + '╖': { [Style.NORMAL]: (xp, yp) => `M${.5 + xp},1 L${.5 + xp},.5 L0,.5 M${.5 - xp},.5 L${.5 - xp},1` }, + '╗': { [Style.NORMAL]: (xp, yp) => `M0,${.5 + yp} L${.5 - xp},${.5 + yp} L${.5 - xp},1 M0,${.5 - yp} L${.5 + xp},${.5 - yp} L${.5 + xp},1` }, + '╘': { [Style.NORMAL]: (xp, yp) => `M.5,0 L.5,${.5 + yp} L1,${.5 + yp} M.5,${.5 - yp} L1,${.5 - yp}` }, + '╙': { [Style.NORMAL]: (xp, yp) => `M1,.5 L${.5 - xp},.5 L${.5 - xp},0 M${.5 + xp},.5 L${.5 + xp},0` }, + '╚': { [Style.NORMAL]: (xp, yp) => `M1,${.5 - yp} L${.5 + xp},${.5 - yp} L${.5 + xp},0 M1,${.5 + yp} L${.5 - xp},${.5 + yp} L${.5 - xp},0` }, + '╛': { [Style.NORMAL]: (xp, yp) => `M0,${.5 + yp} L.5,${.5 + yp} L.5,0 M0,${.5 - yp} L.5,${.5 - yp}` }, + '╜': { [Style.NORMAL]: (xp, yp) => `M0,.5 L${.5 + xp},.5 L${.5 + xp},0 M${.5 - xp},.5 L${.5 - xp},0 ` }, + '╝': { [Style.NORMAL]: (xp, yp) => `M0,${.5 - yp} L${.5 - xp},${.5 - yp} L${.5 - xp},0 M0,${.5 + yp} L${.5 + xp},${.5 + yp} L${.5 + xp},0` }, + '╞': { [Style.NORMAL]: (xp, yp) => `${Shapes.TOP_TO_BOTTOM} M.5,${.5 - yp} L1,${.5 - yp} M.5,${.5 + yp} L1,${.5 + yp}` }, + '╟': { [Style.NORMAL]: (xp, yp) => `M${.5 - xp},0 L${.5 - xp},1 M${.5 + xp},0 L${.5 + xp},1 M${.5 + xp},.5 L1,.5` }, + '╠': { [Style.NORMAL]: (xp, yp) => `M${.5 - xp},0 L${.5 - xp},1 M1,${.5 + yp} L${.5 + xp},${.5 + yp} L${.5 + xp},1 M1,${.5 - yp} L${.5 + xp},${.5 - yp} L${.5 + xp},0` }, + '╡': { [Style.NORMAL]: (xp, yp) => `${Shapes.TOP_TO_BOTTOM} M0,${.5 - yp} L.5,${.5 - yp} M0,${.5 + yp} L.5,${.5 + yp}` }, + '╢': { [Style.NORMAL]: (xp, yp) => `M0,.5 L${.5 - xp},.5 M${.5 - xp},0 L${.5 - xp},1 M${.5 + xp},0 L${.5 + xp},1` }, + '╣': { [Style.NORMAL]: (xp, yp) => `M${.5 + xp},0 L${.5 + xp},1 M0,${.5 + yp} L${.5 - xp},${.5 + yp} L${.5 - xp},1 M0,${.5 - yp} L${.5 - xp},${.5 - yp} L${.5 - xp},0` }, + '╤': { [Style.NORMAL]: (xp, yp) => `M0,${.5 - yp} L1,${.5 - yp} M0,${.5 + yp} L1,${.5 + yp} M.5,${.5 + yp} L.5,1` }, + '╥': { [Style.NORMAL]: (xp, yp) => `${Shapes.LEFT_TO_RIGHT} M${.5 - xp},.5 L${.5 - xp},1 M${.5 + xp},.5 L${.5 + xp},1` }, + '╦': { [Style.NORMAL]: (xp, yp) => `M0,${.5 - yp} L1,${.5 - yp} M0,${.5 + yp} L${.5 - xp},${.5 + yp} L${.5 - xp},1 M1,${.5 + yp} L${.5 + xp},${.5 + yp} L${.5 + xp},1` }, + '╧': { [Style.NORMAL]: (xp, yp) => `M.5,0 L.5,${.5 - yp} M0,${.5 - yp} L1,${.5 - yp} M0,${.5 + yp} L1,${.5 + yp}` }, + '╨': { [Style.NORMAL]: (xp, yp) => `${Shapes.LEFT_TO_RIGHT} M${.5 - xp},.5 L${.5 - xp},0 M${.5 + xp},.5 L${.5 + xp},0` }, + '╩': { [Style.NORMAL]: (xp, yp) => `M0,${.5 + yp} L1,${.5 + yp} M0,${.5 - yp} L${.5 - xp},${.5 - yp} L${.5 - xp},0 M1,${.5 - yp} L${.5 + xp},${.5 - yp} L${.5 + xp},0` }, + '╪': { [Style.NORMAL]: (xp, yp) => `${Shapes.TOP_TO_BOTTOM} M0,${.5 - yp} L1,${.5 - yp} M0,${.5 + yp} L1,${.5 + yp}` }, + '╫': { [Style.NORMAL]: (xp, yp) => `${Shapes.LEFT_TO_RIGHT} M${.5 - xp},0 L${.5 - xp},1 M${.5 + xp},0 L${.5 + xp},1` }, + '╬': { [Style.NORMAL]: (xp, yp) => `M0,${.5 + yp} L${.5 - xp},${.5 + yp} L${.5 - xp},1 M1,${.5 + yp} L${.5 + xp},${.5 + yp} L${.5 + xp},1 M0,${.5 - yp} L${.5 - xp},${.5 - yp} L${.5 - xp},0 M1,${.5 - yp} L${.5 + xp},${.5 - yp} L${.5 + xp},0` }, + + // Diagonal + '╱': { [Style.NORMAL]: 'M1,0 L0,1' }, + '╲': { [Style.NORMAL]: 'M0,0 L1,1' }, + '╳': { [Style.NORMAL]: 'M1,0 L0,1 M0,0 L1,1' }, + + // Mixed weight + '┑': { [Style.NORMAL]: `${bottomYAxisFromBottom}`, [Style.BOLD]: `${leftMiddleXAxis}` }, + '┒': { [Style.NORMAL]: `${leftMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom}` }, + '┕': { [Style.NORMAL]: `${topYAxisFromTop}`, [Style.BOLD]: `${rightMiddleXAxis}` }, + '┖': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromTop}` }, + '┙': { [Style.NORMAL]: `${topYAxisFromTop}`, [Style.BOLD]: `${leftMiddleXAxis}` }, + '┚': { [Style.NORMAL]: `${leftMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromTop}` }, + '┝': { [Style.NORMAL]: `${yAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, + '┞': { [Style.NORMAL]: `${bottomYAxisFromMiddle} ${rightMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromTop}` }, + '┟': { [Style.NORMAL]: `${topYAxisFromMiddle} ${rightMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom}` }, + '┠': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${yAxis}` }, + '┡': { [Style.NORMAL]: `${bottomYAxisFromBottom}`, [Style.BOLD]: `${topYAxisFromMiddle} ${rightMiddleXAxis}` }, + '┢': { [Style.NORMAL]: `${topYAxisFromMiddle}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` }, + '┥': { [Style.NORMAL]: `${yAxis}`, [Style.BOLD]: `${leftMiddleXAxis}` }, + '┦': { [Style.NORMAL]: `${bottomYAxisFromMiddle} ${leftMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromTop}` }, + '┧': { [Style.NORMAL]: `${topYAxisFromMiddle}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` }, + '┨': { [Style.NORMAL]: `${leftMiddleXAxis}`, [Style.BOLD]: `${yAxis}` }, + '┩': { [Style.NORMAL]: `${bottomYAxisFromMiddle}`, [Style.BOLD]: `${topYAxisFromMiddle} ${leftMiddleXAxis}` }, + '┪': { [Style.NORMAL]: `${topYAxisFromMiddle}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` }, + '┭': { [Style.NORMAL]: `${bottomYAxisFromBottom} ${rightMiddleXAxis}`, [Style.BOLD]: `${leftMiddleXAxis}` }, + '┮': { [Style.NORMAL]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, + '┯': { [Style.NORMAL]: `${bottomYAxisFromBottom}`, [Style.BOLD]: `${leftMiddleXAxis} ${rightMiddleXAxis}` }, + '┰': { [Style.NORMAL]: `${xAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom}` }, + '┱': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` }, + '┲': { [Style.NORMAL]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, + '┵': { [Style.NORMAL]: `${topYAxisFromMiddle} ${rightMiddleXAxis}`, [Style.BOLD]: `${leftMiddleXAxis}` }, + '┶': { [Style.NORMAL]: `${topYAxisFromMiddle} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, + '┷': { [Style.NORMAL]: `${topYAxisFromMiddle}`, [Style.BOLD]: `${leftMiddleXAxis} ${rightMiddleXAxis}` }, + '┸': { [Style.NORMAL]: `${xAxis}`, [Style.BOLD]: `${topYAxisFromMiddle}` }, + '┹': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromMiddle} ${leftMiddleXAxis}` }, + '┺': { [Style.NORMAL]: `${topYAxisFromMiddle} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, + '┽': { [Style.NORMAL]: `${yAxis} ${rightMiddleXAxis}`, [Style.BOLD]: `${leftMiddleXAxis}` }, + '┾': { [Style.NORMAL]: `${yAxis} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, + '┿': { [Style.NORMAL]: `${yAxis}`, [Style.BOLD]: `${leftMiddleXAxis} ${rightMiddleXAxis}` }, + '╀': { [Style.NORMAL]: `${xAxis}`, [Style.BOLD]: `${yAxis}` }, + '╁': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${yAxis} ${leftMiddleXAxis}` }, + '╂': { [Style.NORMAL]: `${yAxis} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, + '╃': { [Style.NORMAL]: `${bottomYAxisFromBottom} ${rightMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromTop} ${leftMiddleXAxis}` }, + '╄': { [Style.NORMAL]: `${topYAxisFromTop} ${leftMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` }, + '╅': { [Style.NORMAL]: `${topYAxisFromTop} ${rightMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` }, + '╆': { [Style.NORMAL]: `${topYAxisFromTop} ${leftMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` }, + '╇': { [Style.NORMAL]: `${bottomYAxisFromBottom}`, [Style.BOLD]: `${leftMiddleXAxis} ${topYAxisFromTop} ${rightMiddleXAxis}` }, + '╈': { [Style.NORMAL]: `${topYAxisFromTop}`, [Style.BOLD]: `${leftMiddleXAxis} ${bottomYAxisFromBottom} ${rightMiddleXAxis}` }, + '╉': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${leftMiddleXAxis} ${yAxis}` }, + '╊': { [Style.NORMAL]: `${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis} ${yAxis}` }, + '╼': { [Style.NORMAL]: `${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, + '╽': { [Style.NORMAL]: `${topYAxisFromMiddle}`, [Style.BOLD]: `${bottomYAxisFromBottom}` }, + '╾': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${leftMiddleXAxis}` }, + '╿': { [Style.NORMAL]: `${bottomYAxisFromBottom}`, [Style.BOLD]: `${topYAxisFromMiddle}` }, + + // Dashed + '╌': { [Style.NORMAL]: `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}` }, + '╍': { [Style.BOLD]: `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}` }, + '┄': { [Style.NORMAL]: `` }, + '┅': { [Style.BOLD]: `` }, + '┈': { [Style.NORMAL]: `` }, + '┉': { [Style.BOLD]: `` }, + '╎': { [Style.NORMAL]: `${MOVE}${CENTER.TOP} ${TO}${'.5,.45'} ${MOVE}${'.5,.55'} ${TO}${CENTER.BOTTOM}` }, + '╏': { [Style.BOLD]: `${MOVE}${CENTER.TOP} ${TO}${'.5,.45'} ${MOVE}${'.5,.55'} ${TO}${CENTER.BOTTOM}` }, + '┆': { [Style.NORMAL]: `` }, + '┇': { [Style.BOLD]: `` }, + '┊': { [Style.NORMAL]: `` }, + '┋': { [Style.BOLD]: `` } }; const chars: { [index: string]: string } = { @@ -630,17 +451,30 @@ const chars: { [index: string]: string } = { // // '╳': `${MOVE}${} ${TO}${} ${TO}${}`, }; +// Give more specific name export function draw(ctx: CanvasRenderingContext2D, c: string, xOffset: number, yOffset: number, cellWidth: number, cellHeight: number): void { - const match: { [fontWeight: number]: string } = map[c]; + const match: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } = map[c]; if (!match) { return; } for (const [fontWeight, instructions] of Object.entries(match)) { ctx.beginPath(); ctx.lineWidth = window.devicePixelRatio * Number.parseInt(fontWeight); - for (const instruction of instructions.split(' ')) { + let actualInstructions: string; + if (typeof instructions === 'function') { + const xp = .15; + const yp = .15 / cellHeight * cellWidth; + actualInstructions = instructions(xp, yp); + } else { + actualInstructions = instructions; + } + for (const instruction of actualInstructions.split(' ')) { const type = instruction[0]; const f = instructionMap[type]; + if (!f) { + console.error(`Could not find drawing instructions for "${type}"`); + continue; + } const coords: string[] = instruction.substring(1).split(','); if (!coords[0] || !coords[1]) { continue; @@ -670,8 +504,7 @@ function clamp(value: number, max: number, min: number = 0): number { const instructionMap: { [index: string]: any } = { 'M': (ctx: CanvasRenderingContext2D, x: number, y: number) => { - ctx.moveTo(x, y); - }, + ctx.moveTo(x, y); }, 'L': (ctx: CanvasRenderingContext2D, x: number, y: number) => { ctx.lineTo(x, y); } From 7549f0e92410f78007cdf29cd73c504eaec29c47 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 13 Aug 2021 15:09:04 -0700 Subject: [PATCH 084/164] Clean up --- demo/client.ts | 4 ++-- src/browser/renderer/BoxAndBlockCharacters.ts | 21 +++---------------- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/demo/client.ts b/demo/client.ts index d7c0f8404..cc4679081 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -261,8 +261,8 @@ function runFakeTerminal(): void { term.write('└─┴─┘ ┗━┻━┛ ╚═╩═╝ └┴┘└┴┘└┺┛┗┹┘ └┴┘└┶┛┗┻┛┗┵┘\n\r'); term.write('\n\r'); term.write('Other:\n\r'); - term.write('╭─╮ ╲ ╱ ╷╻╎╏┆┇┊┋ ╺╾╴ ╌╌ ┄┄ ┈┈\n\r'); - term.write('│ │ ╳ ╽╿╎╏┆┇┊┋ ╶╼╸ ╍╍ ┅┅ ┉┉\n\r'); + term.write('╭─╮ ╲ ╱ ╷╻╎╏┆┇┊┋ ╺╾╴ ╌╌╌ ┄┄┄ ┈┈┈\n\r'); + term.write('│ │ ╳ ╽╿╎╏┆┇┊┋ ╶╼╸ ╍╍╍ ┅┅┅ ┉┉┉\n\r'); term.write('╰─╯ ╱ ╲ ╹╵╎╏┆┇┊┋\n\r'); term.write('\n\r'); term.write('All box drawing characters:\n\r'); diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index c220c9aa6..9d99c2851 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -243,22 +243,6 @@ const topYAxisFromMiddle = `${MOVE}${CENTER.TOP} ${TO}${CENTER.MIDDLE}`; const rightMiddleXAxis = `${MOVE}${CENTER.MIDDLE} ${TO}${RIGHT.MIDDLE}`; const leftMiddleXAxis = `${MOVE}${CENTER.MIDDLE} ${TO}${LEFT.MIDDLE}`; -const topXLine = `${MOVE}${'0,.45'} ${TO}${'1,.45'}`; -const bottomXLine = `${MOVE}${'0,.55'} ${TO}${'1,.55'}`; -const leftYLine = `${MOVE}${'.35,0'} ${TO}${'.35,1'}`; -const rightYLine = `${MOVE}${'.65,0'} ${TO}${'.65,1'}`; - -const leftTopXLine = `${MOVE}${'0,.45'} ${TO}${'.5,.45'}`; -const rightTopXLine = `${MOVE}${'.5,.45'} ${TO}${'1,.45'}`; - -const leftBottomXLine = `${MOVE}${'0,.55'} ${TO}${'.5,.55'}`; -const rightBottomXLine = `${MOVE}${'.5,.55'} ${TO}${'1,.55'}`; - -const bottomLeftYLine = `${MOVE}${'.35,.5'} ${TO}${'.35,1'}`; -const topLeftYLine = `${MOVE}${'.35,0'} ${TO}${'.35,.5'}`; - -const bottomRightYLine = `${MOVE}${'.65,.5'} ${TO}${'.65,1'}`; -const topRightYLine = `${MOVE}${'.65,0'} ${TO}${'.65,.5'}`; const enum Shapes { /** │ */ TOP_TO_BOTTOM = 'M.5,0 L.5,1', @@ -412,9 +396,10 @@ const map: { [character: string]: { [fontWeight: number]: string | ((xp: number, '╿': { [Style.NORMAL]: `${bottomYAxisFromBottom}`, [Style.BOLD]: `${topYAxisFromMiddle}` }, // Dashed - '╌': { [Style.NORMAL]: `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}` }, + // TODO: Spacing dashes evenly, use 1/2 padding on each edge so the line is continuous + '╌': { [Style.NORMAL]: `` }, // `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}` }, '╍': { [Style.BOLD]: `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}` }, - '┄': { [Style.NORMAL]: `` }, + '┄': { [Style.NORMAL]: `M.04,.5 L.96,.5` }, '┅': { [Style.BOLD]: `` }, '┈': { [Style.NORMAL]: `` }, '┉': { [Style.BOLD]: `` }, From 7344d62e81d3b4afaa628fc1cdd1cfbf01cc9f42 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Mon, 16 Aug 2021 09:39:44 -0700 Subject: [PATCH 085/164] clean up --- src/browser/renderer/BaseRenderLayer.ts | 4 +- src/browser/renderer/BoxAndBlockCharacters.ts | 59 +++++++------------ 2 files changed, 22 insertions(+), 41 deletions(-) diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 31773f643..7b85d75eb 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -17,7 +17,7 @@ import { IBufferService, IOptionsService } from 'common/services/Services'; import { throwIfFalsy } from 'browser/renderer/RendererUtils'; import { channels, color, rgba } from 'browser/Color'; import { removeElementFromParent } from 'browser/Dom'; -import { boxDrawingBoxes, boxDrawingLineSegments, draw } from 'browser/renderer/BoxAndBlockCharacters'; +import { boxDrawingBoxes, boxDrawingLineSegments, drawBoxChar } from 'browser/renderer/BoxAndBlockCharacters'; export abstract class BaseRenderLayer implements IRenderLayer { private _canvas: HTMLCanvasElement; @@ -422,7 +422,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { // increase # of pixels when font size incremented by 10 // this._ctx.lineWidth = Math.max(Math.floor(this._optionsService.options.fontSize / 10), 1); // yOffset - verticalCenter - draw(this._ctx, char, xOffset, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); + drawBoxChar(this._ctx, char, xOffset, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); return true; } diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 9d99c2851..cdb8f2599 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -264,6 +264,13 @@ const enum Shapes { /** ┬ */ T_BOTTOM = 'M0,.5 L1,.5 M.5,.5 L.5,1', /** ┼ */ CROSS = 'M0,.5 L1,.5 M.5,0 L.5,1', + + /** ╌ */ TWO_DASHES_HORIZONTAL = 'M.1,.5 L.45,.5 M.55,.5 L.9,.5', + /** ┄ */ THREE_DASHES_HORIZONTAL = 'M.052,.5 L.316,.5 M.0.421,.5 L.6315,.5 M.684,.5 L.947,.5', + /** ┉ */ FOUR_DASHES_HORIZONTAL = 'M.0588,.5 L.235,.5 M.294,.5 L.4705,.5 M.529,.5 L.7058,.5 M.765,.5 L.947,.5', + /** ╌ */ TWO_DASHES_VERTICAL = 'M.5,0 T.5,.45 M.5,.55 T.5,1', + /** ┄ */ THREE_DASHES_VERTICAL = 'M.5,.052 L.5,.316 M.5,.0.368 L.5.632 M.5,.684 L.5,.947', + /** ┉ */ FOUR_DASHES_VERTICAL = 'M.5,.0588 L.5,.235 M.5,.294 L.5,.4705 29 L.5,.7058 M.5,.765 L.5,.947', } const enum Style { @@ -397,47 +404,21 @@ const map: { [character: string]: { [fontWeight: number]: string | ((xp: number, // Dashed // TODO: Spacing dashes evenly, use 1/2 padding on each edge so the line is continuous - '╌': { [Style.NORMAL]: `` }, // `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}` }, - '╍': { [Style.BOLD]: `${MOVE}${LEFT.MIDDLE} ${TO}${'.4,.5'} ${MOVE}${'.6,.5'} ${TO}${RIGHT.MIDDLE}` }, - '┄': { [Style.NORMAL]: `M.04,.5 L.96,.5` }, - '┅': { [Style.BOLD]: `` }, - '┈': { [Style.NORMAL]: `` }, - '┉': { [Style.BOLD]: `` }, - '╎': { [Style.NORMAL]: `${MOVE}${CENTER.TOP} ${TO}${'.5,.45'} ${MOVE}${'.5,.55'} ${TO}${CENTER.BOTTOM}` }, - '╏': { [Style.BOLD]: `${MOVE}${CENTER.TOP} ${TO}${'.5,.45'} ${MOVE}${'.5,.55'} ${TO}${CENTER.BOTTOM}` }, - '┆': { [Style.NORMAL]: `` }, - '┇': { [Style.BOLD]: `` }, - '┊': { [Style.NORMAL]: `` }, - '┋': { [Style.BOLD]: `` } + '╌': { [Style.NORMAL]: Shapes.TWO_DASHES_HORIZONTAL }, + '╍': { [Style.BOLD]: Shapes.TWO_DASHES_HORIZONTAL }, + '┄': { [Style.NORMAL]: Shapes.THREE_DASHES_HORIZONTAL }, + '┅': { [Style.BOLD]: Shapes.THREE_DASHES_HORIZONTAL }, + '┈': { [Style.NORMAL]: Shapes.FOUR_DASHES_HORIZONTAL }, + '┉': { [Style.BOLD]: Shapes.FOUR_DASHES_HORIZONTAL }, + '╎': { [Style.NORMAL]: Shapes.TWO_DASHES_VERTICAL }, + '╏': { [Style.BOLD]: Shapes.TWO_DASHES_VERTICAL }, + '┆': { [Style.NORMAL]: Shapes.THREE_DASHES_VERTICAL }, + '┇': { [Style.BOLD]: Shapes.THREE_DASHES_VERTICAL }, + '┊': { [Style.NORMAL]: Shapes.FOUR_DASHES_VERTICAL }, + '┋': { [Style.BOLD]: Shapes.FOUR_DASHES_VERTICAL } }; -const chars: { [index: string]: string } = { -// // '╞': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╟': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╠': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╡': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╢': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╣': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╤': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╥': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╦': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╧': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╨': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╩': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╪': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╫': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╬': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╭': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╮': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╯': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╰': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╱': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╲': `${MOVE}${} ${TO}${} ${TO}${}`, -// // '╳': `${MOVE}${} ${TO}${} ${TO}${}`, -}; - -// Give more specific name -export function draw(ctx: CanvasRenderingContext2D, c: string, xOffset: number, yOffset: number, cellWidth: number, cellHeight: number): void { +export function drawBoxChar(ctx: CanvasRenderingContext2D, c: string, xOffset: number, yOffset: number, cellWidth: number, cellHeight: number): void { const match: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } = map[c]; if (!match) { return; From 62aa91a34dbfb8363fe4415b8658e58523e960e1 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Mon, 16 Aug 2021 09:51:20 -0700 Subject: [PATCH 086/164] clean up --- src/browser/renderer/BaseRenderLayer.ts | 15 +- src/browser/renderer/BoxAndBlockCharacters.ts | 165 ++---------------- 2 files changed, 13 insertions(+), 167 deletions(-) diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 7b85d75eb..44b238402 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -17,7 +17,7 @@ import { IBufferService, IOptionsService } from 'common/services/Services'; import { throwIfFalsy } from 'browser/renderer/RendererUtils'; import { channels, color, rgba } from 'browser/Color'; import { removeElementFromParent } from 'browser/Dom'; -import { boxDrawingBoxes, boxDrawingLineSegments, drawBoxChar } from 'browser/renderer/BoxAndBlockCharacters'; +import { boxCharacters, boxDrawingBoxes, drawBoxChar } from 'browser/renderer/BoxAndBlockCharacters'; export abstract class BaseRenderLayer implements IRenderLayer { private _canvas: HTMLCanvasElement; @@ -408,21 +408,12 @@ export abstract class BaseRenderLayer implements IRenderLayer { return true; } - const lineSegments = boxDrawingLineSegments[char]; + const lineSegments = boxCharacters[char]; if (!lineSegments) { return false; } - const xOffset = x * this._scaledCellWidth; - const verticalCenter = Math.round(this._scaledCellHeight / 2); - - const yOffset = y * this._scaledCellHeight + this._scaledCharTop + verticalCenter; - // const scale = window.devicePixelRatio; this._ctx.strokeStyle = this._ctx.fillStyle; - - // increase # of pixels when font size incremented by 10 - // this._ctx.lineWidth = Math.max(Math.floor(this._optionsService.options.fontSize / 10), 1); - // yOffset - verticalCenter - drawBoxChar(this._ctx, char, xOffset, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); + drawBoxChar(this._ctx, char, x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); return true; } diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index cdb8f2599..23e769638 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -1,125 +1,3 @@ -export const boxDrawingLineSegments: { [index: string]: any } = { - '─': [{ x1: 0, y1: 3, x2: 6, y2: 3 }], - '━': [{ x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 6, y2: 4 }], - '│': [{ x1: 3, y1: 0, x2: 3, y2: 6 }], - '┃': [{ x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }], - '┌': [{ x1: 6, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], - '┍': [{ x1: 6, y1: 2, x2: 3, y2: 2 }, { x1: 3, y1: 2, x2: 3, y2: 6 }, { x1: 6, y1: 4, x2: 3, y2: 4 }], - '┎': [{ x1: 6, y1: 3, x2: 2, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], - '┏': [{ x1: 6, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 6 }, { x1: 6, y1: 4, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 4, y2: 6 }], - '┐': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], - '┑': [{ x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 3, y1: 2, x2: 3, y2: 6 }, { x1: 0, y1: 4, x2: 3, y2: 4 }], - '┒': [{ x1: 0, y1: 3, x2: 4, y2: 3 }, { x1: 4, y1: 3, x2: 4, y2: 6 }, { x1: 2, y1: 3, x2: 2, y2: 6 }], - '┓': [{ x1: 0, y1: 2, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 4, y2: 6 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }], - '└': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], - '┕': [{ x1: 3, y1: 0, x2: 3, y2: 4 }, { x1: 3, y1: 4, x2: 6, y2: 4 }, { x1: 3, y1: 2, x2: 6, y2: 2 }], - '┖': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 2, y1: 3, x2: 6, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }], - '┗': [{ x1: 2, y1: 0, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 6, y2: 4 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }], - '┘': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 0 }], - '┙': [{ x1: 0, y1: 4, x2: 3, y2: 4 }, { x1: 3, y1: 4, x2: 3, y2: 0 }, { x1: 0, y1: 2, x2: 3, y2: 2 }], - '┚': [{ x1: 0, y1: 3, x2: 4, y2: 3 }, { x1: 4, y1: 3, x2: 4, y2: 0 }, { x1: 2, y1: 3, x2: 2, y2: 0 }], - '┛': [{ x1: 0, y1: 4, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 4, y2: 0 }, { x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }], - '├': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], - '┝': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], - '┞': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }, { x1: 4, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], - '┟': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], - '┠': [{ x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }, { x1: 4, y1: 3, x2: 6, y2: 3 }], - '┡': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 2, y1: 3, x2: 6, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], - '┢': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 2, y1: 6, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 6, y2: 2 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], - '┣': [{ x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }, { x1: 6, y1: 4, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 4, y2: 6 }], - '┤': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 0, y1: 3, x2: 3, y2: 3 }], - '┥': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }], - '┦': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }, { x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], - '┧': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 0, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], - '┨': [{ x1: 0, y1: 3, x2: 2, y2: 3 }, { x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }], - '┩': [{ x1: 2, y1: 0, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 0, y2: 2 }, { x1: 4, y1: 0, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 0, y2: 4 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], - '┪': [{ x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 3, y1: 2, x2: 3, y2: 6 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 3, y1: 0, x2: 3, y2: 3 }], - '┫': [{ x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }], - '┬': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], - '┭': [{ x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }, { x1: 3, y1: 6, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], - '┮': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }, { x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], - '┯': [{ x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 6, y2: 4 }, { x1: 3, y1: 4, x2: 3, y2: 6 }], - '┰': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], - '┱': [{ x1: 0, y1: 2, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 4, y2: 6 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], - '┲': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 2, y1: 6, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 6, y2: 2 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], - '┳': [{ x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], - '┴': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 0, x2: 3, y2: 3 }], - '┵': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }, { x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }], - '┶': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 0 }, { x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], - '┷': [{ x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 6, y2: 4 }, { x1: 3, y1: 0, x2: 3, y2: 3 }], - '┸': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }], - '┹': [{ x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 0, y1: 4, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 4, y2: 0 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], - '┺': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 2, y1: 0, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 6, y2: 4 }, { x1: 3, y1: 0, x2: 3, y2: 2 }, { x1: 3, y1: 2, x2: 6, y2: 2 }], - '┻': [{ x1: 0, y1: 4, x2: 6, y2: 4 }, { x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }], - '┼': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 0, x2: 3, y2: 6 }], - '┽': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 3, y1: 3, x2: 6, y2: 3 }, { x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }], - '┾': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], - '┿': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 6, y2: 4 }], - '╀': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }, { x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }], - '╁': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], - '╂': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }], - '╃': [{ x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 0, y1: 4, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 4, y2: 0 }, { x1: 3, y1: 6, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], - '╄': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }, { x1: 2, y1: 0, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 6, y2: 4 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }], - '╅': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 6, y2: 3 }, { x1: 0, y1: 2, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 4, y2: 6 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }], - '╆': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 0 }, { x1: 2, y1: 6, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 6, y2: 2 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], - '╇': [{ x1: 0, y1: 4, x2: 6, y2: 4 }, { x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 3, x2: 3, y2: 6 }], - '╈': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], - '╉': [{ x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 2, y1: 2, x2: 2, y2: 0 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 2, y1: 4, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], - '╊': [{ x1: 0, y1: 3, x2: 2, y2: 3 }, { x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 4, y1: 2, x2: 6, y2: 2 }, { x1: 4, y1: 6, x2: 4, y2: 4 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], - '╋': [{ x1: 0, y1: 2, x2: 6, y2: 2 }, { x1: 0, y1: 4, x2: 6, y2: 4 }, { x1: 2, y1: 0, x2: 2, y2: 6 }, { x1: 4, y1: 0, x2: 4, y2: 6 }], - '╌': [{ x1: 0, y1: 3, x2: 2, y2: 3 }, { x1: 4, y1: 3, x2: 6, y2: 3 }], - '╍': [{ x1: 0, y1: 2, x2: 2, y2: 2 }, { x1: 0, y1: 4, x2: 2, y2: 4 }, { x1: 4, y1: 2, x2: 6, y2: 2 }, { x1: 4, y1: 4, x2: 6, y2: 4 }], - '╎': [{ x1: 3, y1: 0, x2: 3, y2: 2 }, { x1: 3, y1: 4, x2: 3, y2: 6 }], - '╏': [{ x1: 2, y1: 0, x2: 2, y2: 2 }, { x1: 4, y1: 0, x2: 4, y2: 2 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], - '═': [{ x1: 0, y1: 1, x2: 6, y2: 1 }, { x1: 0, y1: 5, x2: 6, y2: 5 }], - '║': [{ x1: 1, y1: 0, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 6 }], - '╒': [{ x1: 6, y1: 1, x2: 3, y2: 1 }, { x1: 3, y1: 1, x2: 3, y2: 6 }, { x1: 6, y1: 5, x2: 3, y2: 5 }], - '╓': [{ x1: 6, y1: 3, x2: 1, y2: 3 }, { x1: 1, y1: 3, x2: 1, y2: 6 }, { x1: 5, y1: 3, x2: 5, y2: 6 }], - '╔': [{ x1: 6, y1: 1, x2: 1, y2: 1 }, { x1: 1, y1: 1, x2: 1, y2: 6 }, { x1: 6, y1: 5, x2: 5, y2: 5 }, { x1: 5, y1: 5, x2: 5, y2: 6 }], - '╕': [{ x1: 0, y1: 1, x2: 3, y2: 1 }, { x1: 3, y1: 1, x2: 3, y2: 6 }, { x1: 0, y1: 5, x2: 3, y2: 5 }], - '╖': [{ x1: 0, y1: 3, x2: 5, y2: 3 }, { x1: 5, y1: 3, x2: 5, y2: 6 }, { x1: 1, y1: 3, x2: 1, y2: 6 }], - '╗': [{ x1: 0, y1: 1, x2: 5, y2: 1 }, { x1: 5, y1: 1, x2: 5, y2: 6 }, { x1: 0, y1: 5, x2: 1, y2: 5 }, { x1: 1, y1: 5, x2: 1, y2: 6 }], - '╘': [{ x1: 3, y1: 0, x2: 3, y2: 5 }, { x1: 3, y1: 5, x2: 6, y2: 5 }, { x1: 3, y1: 1, x2: 6, y2: 1 }], - '╙': [{ x1: 1, y1: 0, x2: 1, y2: 3 }, { x1: 1, y1: 3, x2: 6, y2: 3 }, { x1: 5, y1: 0, x2: 5, y2: 3 }], - '╚': [{ x1: 1, y1: 0, x2: 1, y2: 5 }, { x1: 1, y1: 5, x2: 6, y2: 5 }, { x1: 5, y1: 0, x2: 5, y2: 1 }, { x1: 5, y1: 1, x2: 6, y2: 1 }], - '╛': [{ x1: 0, y1: 1, x2: 3, y2: 1 }, { x1: 0, y1: 5, x2: 3, y2: 5 }, { x1: 3, y1: 5, x2: 3, y2: 0 }], - '╜': [{ x1: 0, y1: 3, x2: 5, y2: 3 }, { x1: 5, y1: 3, x2: 5, y2: 0 }, { x1: 1, y1: 3, x2: 1, y2: 0 }], - '╝': [{ x1: 0, y1: 1, x2: 1, y2: 1 }, { x1: 1, y1: 1, x2: 1, y2: 0 }, { x1: 0, y1: 5, x2: 5, y2: 5 }, { x1: 5, y1: 5, x2: 5, y2: 0 }], - '╞': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 3, y1: 1, x2: 6, y2: 1 }, { x1: 3, y1: 5, x2: 6, y2: 5 }], - '╟': [{ x1: 1, y1: 0, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 6 }, { x1: 5, y1: 3, x2: 6, y2: 3 }], - '╠': [{ x1: 1, y1: 0, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 1 }, { x1: 5, y1: 1, x2: 6, y2: 1 }, { x1: 5, y1: 6, x2: 5, y2: 5 }, { x1: 5, y1: 5, x2: 6, y2: 5 }], - '╡': [{ x1: 3, y1: 0, x2: 3, y2: 6 }, { x1: 0, y1: 1, x2: 3, y2: 1 }, { x1: 0, y1: 5, x2: 3, y2: 5 }], - '╢': [{ x1: 0, y1: 3, x2: 1, y2: 3 }, { x1: 1, y1: 0, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 6 }], - '╣': [{ x1: 0, y1: 1, x2: 1, y2: 1 }, { x1: 1, y1: 1, x2: 1, y2: 0 }, { x1: 0, y1: 5, x2: 1, y2: 5 }, { x1: 1, y1: 5, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 6 }], - '╤': [{ x1: 0, y1: 1, x2: 6, y2: 1 }, { x1: 0, y1: 5, x2: 6, y2: 5 }, { x1: 3, y1: 5, x2: 3, y2: 6 }], - '╥': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 1, y1: 3, x2: 1, y2: 6 }, { x1: 5, y1: 3, x2: 5, y2: 6 }], - '╦': [{ x1: 0, y1: 1, x2: 6, y2: 1 }, { x1: 0, y1: 5, x2: 1, y2: 5 }, { x1: 1, y1: 5, x2: 1, y2: 6 }, { x1: 5, y1: 6, x2: 5, y2: 5 }, { x1: 5, y1: 5, x2: 6, y2: 5 }], - '╧': [{ x1: 0, y1: 5, x2: 6, y2: 5 }, { x1: 0, y1: 1, x2: 6, y2: 1 }, { x1: 3, y1: 0, x2: 3, y2: 1 }], - '╨': [{ x1: 0, y1: 3, x2: 6, y2: 3 }, { x1: 1, y1: 0, x2: 1, y2: 3 }, { x1: 5, y1: 0, x2: 5, y2: 3 }], - '╩': [{ x1: 0, y1: 1, x2: 1, y2: 1 }, { x1: 1, y1: 1, x2: 1, y2: 0 }, { x1: 5, y1: 0, x2: 5, y2: 1 }, { x1: 5, y1: 1, x2: 6, y2: 1 }, { x1: 0, y1: 5, x2: 6, y2: 5 }], - '╪': [{ x1: 0, y1: 1, x2: 6, y2: 1 }, { x1: 0, y1: 5, x2: 6, y2: 5 }, { x1: 3, y1: 0, x2: 3, y2: 6 }], - '╫': [{ x1: 1, y1: 0, x2: 1, y2: 6 }, { x1: 5, y1: 0, x2: 5, y2: 6 }, { x1: 0, y1: 3, x2: 6, y2: 3 }], - '╬': [{ x1: 0, y1: 1, x2: 1, y2: 1 }, { x1: 1, y1: 1, x2: 1, y2: 0 }, { x1: 5, y1: 0, x2: 5, y2: 1 }, { x1: 5, y1: 1, x2: 6, y2: 1 }, { x1: 6, y1: 5, x2: 5, y2: 5 }, { x1: 5, y1: 5, x2: 5, y2: 6 }, { x1: 1, y1: 6, x2: 1, y2: 5 }, { x1: 1, y1: 5, x2: 0, y2: 5 }], - '╭': [{ x1: 6, y1: 3, x2: 3, y2: 6, cx1: 3, cy1: 3, cx2: 3, cy2: 3 }], - '╮': [{ x1: 0, y1: 3, x2: 3, y2: 6, cx1: 3, cy1: 3, cx2: 3, cy2: 3 }], - '╯': [{ x1: 0, y1: 3, x2: 3, y2: 0, cx1: 3, cy1: 3, cx2: 3, cy2: 3 }], - '╰': [{ x1: 3, y1: 0, x2: 6, y2: 3, cx1: 3, cy1: 3, cx2: 3, cy2: 3 }], - '╱': [{ x1: 0, y1: 6, x2: 6, y2: 0 }], - '╲': [{ x1: 0, y1: 0, x2: 6, y2: 6 }], - '╳': [{ x1: 0, y1: 6, x2: 6, y2: 0 }, { x1: 0, y1: 0, x2: 6, y2: 6 }], - '╴': [{ x1: 0, y1: 3, x2: 3, y2: 3 }], - '╵': [{ x1: 3, y1: 0, x2: 3, y2: 3 }], - '╶': [{ x1: 3, y1: 3, x2: 6, y2: 3 }], - '╷': [{ x1: 3, y1: 3, x2: 3, y2: 6 }], - '╸': [{ x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }], - '╹': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }], - '╺': [{ x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], - '╻': [{ x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], - '╼': [{ x1: 0, y1: 3, x2: 3, y2: 3 }, { x1: 3, y1: 2, x2: 6, y2: 2 }, { x1: 3, y1: 4, x2: 6, y2: 4 }], - '╽': [{ x1: 3, y1: 0, x2: 3, y2: 3 }, { x1: 2, y1: 3, x2: 2, y2: 6 }, { x1: 4, y1: 3, x2: 4, y2: 6 }], - '╾': [{ x1: 0, y1: 2, x2: 3, y2: 2 }, { x1: 0, y1: 4, x2: 3, y2: 4 }, { x1: 3, y1: 3, x2: 6, y2: 3 }], - '╿': [{ x1: 2, y1: 0, x2: 2, y2: 3 }, { x1: 4, y1: 0, x2: 4, y2: 3 }, { x1: 3, y1: 3, x2: 3, y2: 6 }] -}; export const boxDrawingBoxes: { [index: string]: any } = { '▀': [{ x: 0, y: 0, w: 8, h: 4 }], @@ -212,37 +90,14 @@ export const boxDrawingBoxes: { [index: string]: any } = { '\u{1FB97}': [{ x: 0, y: 2, w: 8, h: 2 }, { x: 0, y: 6, w: 8, h: 2 }] }; -export const enum CENTER { - BOTTOM ='.5,1', - TOP = '.5,0', - MIDDLE = '.5,.5' -} - -export const enum LEFT { - BOTTOM = '0,1', - TOP = '0,0', - MIDDLE = '0,.5' -} - -export const enum RIGHT { - BOTTOM = '1,1', - TOP = '1,0', - MIDDLE = '1,.5' -} - -const MOVE = 'M'; -const TO = 'L'; -const THICK = '!'; - -const yAxis = `${MOVE}${CENTER.TOP} ${TO}${CENTER.BOTTOM}`; -const xAxis = `${MOVE}${LEFT.MIDDLE} ${TO}${RIGHT.MIDDLE}`; -const bottomYAxisFromBottom = `${MOVE}${CENTER.BOTTOM} ${TO}${CENTER.MIDDLE}`; -const bottomYAxisFromMiddle = `${MOVE}${CENTER.MIDDLE} ${TO}${CENTER.BOTTOM}`; -const topYAxisFromTop = `${MOVE}${CENTER.TOP} ${TO}${CENTER.MIDDLE}`; -const topYAxisFromMiddle = `${MOVE}${CENTER.TOP} ${TO}${CENTER.MIDDLE}`; -const rightMiddleXAxis = `${MOVE}${CENTER.MIDDLE} ${TO}${RIGHT.MIDDLE}`; -const leftMiddleXAxis = `${MOVE}${CENTER.MIDDLE} ${TO}${LEFT.MIDDLE}`; - +const yAxis = `M.5,0 L.5,1`; +const xAxis = `M0,.5 L1,.5`; +const bottomYAxisFromBottom = `M.5,1 L.5,.5`; +const bottomYAxisFromMiddle = `M.5,.5 L.5,1`; +const topYAxisFromTop = `M.5,0 L.5,.5`; +const topYAxisFromMiddle = `M.5,0 L.5,.5`; +const rightMiddleXAxis = `M.5,.5 L1,.5`; +const leftMiddleXAxis = `M.5,.5 L0,.5`; const enum Shapes { /** │ */ TOP_TO_BOTTOM = 'M.5,0 L.5,1', @@ -279,7 +134,7 @@ const enum Style { } // TODO: Tweak normal and bold weights -const map: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } } = { +export const boxCharacters: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } } = { // Uniform normal and bold '─': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT }, '━': { [Style.BOLD]: Shapes.LEFT_TO_RIGHT }, @@ -419,7 +274,7 @@ const map: { [character: string]: { [fontWeight: number]: string | ((xp: number, }; export function drawBoxChar(ctx: CanvasRenderingContext2D, c: string, xOffset: number, yOffset: number, cellWidth: number, cellHeight: number): void { - const match: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } = map[c]; + const match: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } = boxCharacters[c]; if (!match) { return; } From 012468785b13ab9035dff84ed1f74424eed24bd4 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 16 Aug 2021 12:23:34 -0700 Subject: [PATCH 087/164] Clean up serialize addon --- .../src/SerializeAddon.ts | 93 +++++----- .../test/SerializeAddon.api.ts | 164 +++++++++--------- .../typings/xterm-addon-serialize.d.ts | 14 +- 3 files changed, 134 insertions(+), 137 deletions(-) diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index 0caaaa039..5cd834b86 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -13,7 +13,10 @@ function constrain(value: number, low: number, high: number): number { // TODO: Refine this template class later abstract class BaseSerializeHandler { - constructor(private _buffer: IBuffer) { } + constructor( + protected readonly _buffer: IBuffer + ) { + } public serialize(startRow: number, endRow: number): string { // we need two of them to flip between old and new cell @@ -71,8 +74,6 @@ function equalFlags(cell1: IBufferCell, cell2: IBufferCell): boolean { && cell1.isDim() === cell2.isDim(); } - - class StringSerializeHandler extends BaseSerializeHandler { private _rowIndex: number = 0; private _allRows: string[] = new Array(); @@ -83,7 +84,7 @@ class StringSerializeHandler extends BaseSerializeHandler { // we can see a full colored cell and a null cell that only have background the same style // but the information isn't preserved by null cell itself // so wee need to record it when required. - private _cursorStyle: IBufferCell = this._buffer1.getNullCell(); + private _cursorStyle: IBufferCell = this._buffer.getNullCell(); // where exact the cursor styles comes from // because we can't copy the cell directly @@ -92,7 +93,7 @@ class StringSerializeHandler extends BaseSerializeHandler { private _cursorStyleCol: number = 0; // this is a null cell for reference for checking whether background is empty or not - private _backgroundCell: IBufferCell = this._buffer1.getNullCell(); + private _backgroundCell: IBufferCell = this._buffer.getNullCell(); private _firstRow: number = 0; private _lastCursorRow: number = 0; @@ -100,8 +101,11 @@ class StringSerializeHandler extends BaseSerializeHandler { private _lastContentCursorRow: number = 0; private _lastContentCursorCol: number = 0; - constructor(private _buffer1: IBuffer, private _terminal: Terminal) { - super(_buffer1); + constructor( + buffer: IBuffer, + private readonly _terminal: Terminal + ) { + super(buffer); } protected _beforeSerialize(rows: number, start: number, end: number): void { @@ -111,14 +115,14 @@ class StringSerializeHandler extends BaseSerializeHandler { this._firstRow = start; } - private _thisRowLastChar: IBufferCell = this._buffer1.getNullCell(); - private _thisRowLastSecondChar: IBufferCell = this._buffer1.getNullCell(); - private _nextRowFirstChar: IBufferCell = this._buffer1.getNullCell(); + private _thisRowLastChar: IBufferCell = this._buffer.getNullCell(); + private _thisRowLastSecondChar: IBufferCell = this._buffer.getNullCell(); + private _nextRowFirstChar: IBufferCell = this._buffer.getNullCell(); protected _rowEnd(row: number, isLastRow: boolean): void { // if there is colorful empty cell at line end, whe must pad it back, or the the color block will missing if (this._nullCellCount > 0 && !equalBg(this._cursorStyle, this._backgroundCell)) { // use clear right to set background. - this._currentRow += `\x1b[${this._nullCellCount}X`; + this._currentRow += `\u001b[${this._nullCellCount}X`; } let rowSeparator = ''; @@ -127,13 +131,13 @@ class StringSerializeHandler extends BaseSerializeHandler { if (!isLastRow) { // Enable BCE if (row - this._firstRow >= this._terminal.rows) { - this._buffer1.getLine(this._cursorStyleRow)?.getCell(this._cursorStyleCol, this._backgroundCell); + this._buffer.getLine(this._cursorStyleRow)?.getCell(this._cursorStyleCol, this._backgroundCell); } // Fetch current line - const currentLine = this._buffer1.getLine(row)!; + const currentLine = this._buffer.getLine(row)!; // Fetch next line - const nextLine = this._buffer1.getLine(row + 1)!; + const nextLine = this._buffer.getLine(row + 1)!; if (!nextLine.isWrapped) { // just insert the line break @@ -187,15 +191,15 @@ class StringSerializeHandler extends BaseSerializeHandler { // insert enough character to force the wrap rowSeparator = '-'.repeat(this._nullCellCount + 1); // move back and erase next line head - rowSeparator += '\x1b[1D\x1b[1X'; + rowSeparator += '\u001b[1D\u001b[1X'; if (this._nullCellCount > 0) { // do these because we filled the last several null slot, which we shouldn't - rowSeparator += '\x1b[A'; - rowSeparator += `\x1b[${currentLine.length - this._nullCellCount}C`; - rowSeparator += `\x1b[${this._nullCellCount}X`; - rowSeparator += `\x1b[${currentLine.length - this._nullCellCount}D`; - rowSeparator += '\x1b[B'; + rowSeparator += '\u001b[A'; + rowSeparator += `\u001b[${currentLine.length - this._nullCellCount}C`; + rowSeparator += `\u001b[${this._nullCellCount}X`; + rowSeparator += `\u001b[${currentLine.length - this._nullCellCount}D`; + rowSeparator += '\u001b[B'; } // This is content and need the be serialized even it is invisible. @@ -285,20 +289,20 @@ class StringSerializeHandler extends BaseSerializeHandler { if (this._nullCellCount > 0) { // use clear right to set background. if (!equalBg(this._cursorStyle, this._backgroundCell)) { - this._currentRow += `\x1b[${this._nullCellCount}X`; + this._currentRow += `\u001b[${this._nullCellCount}X`; } // use move right to move cursor. - this._currentRow += `\x1b[${this._nullCellCount}C`; + this._currentRow += `\u001b[${this._nullCellCount}C`; this._nullCellCount = 0; } this._lastContentCursorRow = this._lastCursorRow = row; this._lastContentCursorCol = this._lastCursorCol = col; - this._currentRow += `\x1b[${sgrSeq.join(';')}m`; + this._currentRow += `\u001b[${sgrSeq.join(';')}m`; // update the last cursor style - const line = this._buffer1.getLine(row); + const line = this._buffer.getLine(row); if (line !== undefined) { line.getCell(col, this._cursorStyle); this._cursorStyleRow = row; @@ -317,10 +321,10 @@ class StringSerializeHandler extends BaseSerializeHandler { // because style change is handled by previous stage // use move right when background is empty, use clear right when there is background. if (equalBg(this._cursorStyle, this._backgroundCell)) { - this._currentRow += `\x1b[${this._nullCellCount}C`; + this._currentRow += `\u001b[${this._nullCellCount}C`; } else { - this._currentRow += `\x1b[${this._nullCellCount}X`; - this._currentRow += `\x1b[${this._nullCellCount}C`; + this._currentRow += `\u001b[${this._nullCellCount}X`; + this._currentRow += `\u001b[${this._nullCellCount}C`; } this._nullCellCount = 0; } @@ -338,7 +342,7 @@ class StringSerializeHandler extends BaseSerializeHandler { // the fixup is only required for data without scrollback // because it will always be placed at last line otherwise - if (this._buffer1.length - this._firstRow <= this._terminal.rows) { + if (this._buffer.length - this._firstRow <= this._terminal.rows) { rowEnd = this._lastContentCursorRow + 1 - this._firstRow; this._lastCursorCol = this._lastContentCursorCol; this._lastCursorRow = this._lastContentCursorRow; @@ -354,8 +358,8 @@ class StringSerializeHandler extends BaseSerializeHandler { } // restore the cursor - const realCursorRow = this._buffer1.baseY + this._buffer1.cursorY; - const realCursorCol = this._buffer1.cursorX; + const realCursorRow = this._buffer.baseY + this._buffer.cursorY; + const realCursorCol = this._buffer.cursorX; const cursorMoved = (realCursorRow !== this._lastCursorRow || realCursorCol !== this._lastCursorCol); @@ -379,7 +383,6 @@ class StringSerializeHandler extends BaseSerializeHandler { moveRight(realCursorCol - this._lastCursorCol); } - return content; } } @@ -393,14 +396,11 @@ export class SerializeAddon implements ITerminalAddon { this._terminal = terminal; } - private _getString(buffer: IBuffer, scrollback?: number): string { + private _serializeBuffer(terminal: Terminal, buffer: IBuffer, scrollback?: number): string { const maxRows = buffer.length; - const handler = new StringSerializeHandler(buffer, this._terminal!); - - const correctRows = (scrollback === undefined) ? maxRows : constrain(scrollback + this!._terminal!.rows, 0, maxRows); - const result = handler.serialize(maxRows - correctRows, maxRows); - - return result; + const handler = new StringSerializeHandler(buffer, terminal); + const correctRows = (scrollback === undefined) ? maxRows : constrain(scrollback + terminal.rows, 0, maxRows); + return handler.serialize(maxRows - correctRows, maxRows); } public serialize(scrollback?: number): string { @@ -409,17 +409,16 @@ export class SerializeAddon implements ITerminalAddon { throw new Error('Cannot use addon until it has been loaded'); } - if (this._terminal.buffer.active.type === 'normal') { - return this._getString(this._terminal.buffer.active, scrollback); + // Normal buffer + let content = this._serializeBuffer(this._terminal, this._terminal.buffer.normal, scrollback); + + // Alternate buffer + if (this._terminal.buffer.active.type === 'alternate') { + const alternativeScreenContent = this._serializeBuffer(this._terminal, this._terminal.buffer.alternate, undefined); + content += `\u001b[?1049h\u001b[H${alternativeScreenContent}`; } - const normalScreenContent = this._getString(this._terminal.buffer.normal, scrollback); - // alt screen don't have scrollback - const alternativeScreenContent = this._getString(this._terminal.buffer.alternate, undefined); - - return normalScreenContent - + '\u001b[?1049h\u001b[H' - + alternativeScreenContent; + return content; } public dispose(): void { } diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index c46b3815c..c8b7302f6 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -89,8 +89,6 @@ describe('SerializeAddon', () => { }); it('empty content', async function(): Promise { - const rows = 10; - const cols = 10; assert.equal(await page.evaluate(`serializeAddon.serialize();`), ''); }); @@ -177,17 +175,17 @@ describe('SerializeAddon', () => { const cols = 10; const line = '+'.repeat(cols); const lines: string[] = [ - mkSGR(FG_P16_GREEN) + line, // Workaround: If we clear all flags a the end, serialize will use \x1b[0m to clear instead of the sepcific disable sequence - mkSGR(INVERSE) + line, - mkSGR(BOLD) + line, - mkSGR(UNDERLINED) + line, - mkSGR(BLINK) + line, - mkSGR(INVISIBLE) + line, - mkSGR(NO_INVERSE) + line, - mkSGR(NO_BOLD) + line, - mkSGR(NO_UNDERLINED) + line, - mkSGR(NO_BLINK) + line, - mkSGR(NO_INVISIBLE) + line + sgr(FG_P16_GREEN) + line, // Workaround: If we clear all flags a the end, serialize will use \x1b[0m to clear instead of the sepcific disable sequence + sgr(INVERSE) + line, + sgr(BOLD) + line, + sgr(UNDERLINED) + line, + sgr(BLINK) + line, + sgr(INVISIBLE) + line, + sgr(NO_INVERSE) + line, + sgr(NO_BOLD) + line, + sgr(NO_UNDERLINED) + line, + sgr(NO_BLINK) + line, + sgr(NO_INVISIBLE) + line ]; const rows = lines.length; await writeSync(page, lines.join('\\r\\n')); @@ -209,16 +207,16 @@ describe('SerializeAddon', () => { const cols = 10; const line = '+'.repeat(cols); const lines: string[] = [ - mkSGR(FG_P16_RED) + line, // fg Red, - mkSGR(UNDERLINED) + line, // fg Red, Underlined - mkSGR(FG_P16_GREEN) + line, // fg Green, Underlined - mkSGR(INVERSE) + line, // fg Green, Underlined, Inverse - mkSGR(NO_INVERSE) + line, // fg Green, Underlined - mkSGR(INVERSE) + line, // fg Green, Underlined, Inverse - mkSGR(BG_P16_YELLOW) + line, // fg Green, bg Yellow, Underlined, Inverse - mkSGR(FG_RESET) + line, // bg Yellow, Underlined, Inverse - mkSGR(BG_RESET) + line, // Underlined, Inverse - mkSGR(NORMAL) + line // Back to normal + sgr(FG_P16_RED) + line, // fg Red, + sgr(UNDERLINED) + line, // fg Red, Underlined + sgr(FG_P16_GREEN) + line, // fg Green, Underlined + sgr(INVERSE) + line, // fg Green, Underlined, Inverse + sgr(NO_INVERSE) + line, // fg Green, Underlined + sgr(INVERSE) + line, // fg Green, Underlined, Inverse + sgr(BG_P16_YELLOW) + line, // fg Green, bg Yellow, Underlined, Inverse + sgr(FG_RESET) + line, // bg Yellow, Underlined, Inverse + sgr(BG_RESET) + line, // Underlined, Inverse + sgr(NORMAL) + line // Back to normal ]; await writeSync(page, lines.join('\\r\\n')); assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n')); @@ -228,19 +226,19 @@ describe('SerializeAddon', () => { const cols = 10; const line = '+'.repeat(cols); const lines: string[] = [ - mkSGR(FG_P16_RED) + line, // fg Red - mkSGR(FG_P16_GREEN, BG_P16_YELLOW) + line, // fg Green, bg Yellow - mkSGR(UNDERLINED, ITALIC) + line, // fg Green, bg Yellow, Underlined, Italic - mkSGR(NO_UNDERLINED, NO_ITALIC) + line, // fg Green, bg Yellow - mkSGR(FG_RESET, ITALIC) + line, // bg Yellow, Italic - mkSGR(BG_RESET) + line, // Italic - mkSGR(NORMAL) + line, // Back to normal - mkSGR(FG_P16_RED) + line, // fg Red - mkSGR(FG_P16_GREEN, BG_P16_YELLOW) + line, // fg Green, bg Yellow - mkSGR(UNDERLINED, ITALIC) + line, // fg Green, bg Yellow, Underlined, Italic - mkSGR(NO_UNDERLINED, NO_ITALIC) + line, // fg Green, bg Yellow - mkSGR(FG_RESET, ITALIC) + line, // bg Yellow, Italic - mkSGR(BG_RESET) + line // Italic + sgr(FG_P16_RED) + line, // fg Red + sgr(FG_P16_GREEN, BG_P16_YELLOW) + line, // fg Green, bg Yellow + sgr(UNDERLINED, ITALIC) + line, // fg Green, bg Yellow, Underlined, Italic + sgr(NO_UNDERLINED, NO_ITALIC) + line, // fg Green, bg Yellow + sgr(FG_RESET, ITALIC) + line, // bg Yellow, Italic + sgr(BG_RESET) + line, // Italic + sgr(NORMAL) + line, // Back to normal + sgr(FG_P16_RED) + line, // fg Red + sgr(FG_P16_GREEN, BG_P16_YELLOW) + line, // fg Green, bg Yellow + sgr(UNDERLINED, ITALIC) + line, // fg Green, bg Yellow, Underlined, Italic + sgr(NO_UNDERLINED, NO_ITALIC) + line, // fg Green, bg Yellow + sgr(FG_RESET, ITALIC) + line, // bg Yellow, Italic + sgr(BG_RESET) + line // Italic ]; await writeSync(page, lines.join('\\r\\n')); assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n')); @@ -250,16 +248,16 @@ describe('SerializeAddon', () => { const cols = 10; const line = '+'.repeat(cols); const lines: string[] = [ - mkSGR(FG_P256_RED) + line, // fg Red 256, - mkSGR(UNDERLINED) + line, // fg Red 256, Underlined - mkSGR(FG_P256_GREEN) + line, // fg Green 256, Underlined - mkSGR(INVERSE) + line, // fg Green 256, Underlined, Inverse - mkSGR(NO_INVERSE) + line, // fg Green 256, Underlined - mkSGR(INVERSE) + line, // fg Green 256, Underlined, Inverse - mkSGR(BG_P256_YELLOW) + line, // fg Green 256, bg Yellow 256, Underlined, Inverse - mkSGR(FG_RESET) + line, // bg Yellow 256, Underlined, Inverse - mkSGR(BG_RESET) + line, // Underlined, Inverse - mkSGR(NORMAL) + line // Back to normal + sgr(FG_P256_RED) + line, // fg Red 256, + sgr(UNDERLINED) + line, // fg Red 256, Underlined + sgr(FG_P256_GREEN) + line, // fg Green 256, Underlined + sgr(INVERSE) + line, // fg Green 256, Underlined, Inverse + sgr(NO_INVERSE) + line, // fg Green 256, Underlined + sgr(INVERSE) + line, // fg Green 256, Underlined, Inverse + sgr(BG_P256_YELLOW) + line, // fg Green 256, bg Yellow 256, Underlined, Inverse + sgr(FG_RESET) + line, // bg Yellow 256, Underlined, Inverse + sgr(BG_RESET) + line, // Underlined, Inverse + sgr(NORMAL) + line // Back to normal ]; await writeSync(page, lines.join('\\r\\n')); assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n')); @@ -269,19 +267,19 @@ describe('SerializeAddon', () => { const cols = 10; const line = '+'.repeat(cols); const lines: string[] = [ - mkSGR(FG_P256_RED) + line, // fg Red 256 - mkSGR(FG_P256_GREEN, BG_P256_YELLOW) + line, // fg Green 256, bg Yellow 256 - mkSGR(UNDERLINED, ITALIC) + line, // fg Green 256, bg Yellow 256, Underlined, Italic - mkSGR(NO_UNDERLINED, NO_ITALIC) + line, // fg Green 256, bg Yellow 256 - mkSGR(FG_RESET, ITALIC) + line, // bg Yellow 256, Italic - mkSGR(BG_RESET) + line, // Italic - mkSGR(NORMAL) + line, // Back to normal - mkSGR(FG_P256_RED) + line, // fg Red 256 - mkSGR(FG_P256_GREEN, BG_P256_YELLOW) + line, // fg Green 256, bg Yellow 256 - mkSGR(UNDERLINED, ITALIC) + line, // fg Green 256, bg Yellow 256, Underlined, Italic - mkSGR(NO_UNDERLINED, NO_ITALIC) + line, // fg Green 256, bg Yellow 256 - mkSGR(FG_RESET, ITALIC) + line, // bg Yellow 256, Italic - mkSGR(BG_RESET) + line // Italic + sgr(FG_P256_RED) + line, // fg Red 256 + sgr(FG_P256_GREEN, BG_P256_YELLOW) + line, // fg Green 256, bg Yellow 256 + sgr(UNDERLINED, ITALIC) + line, // fg Green 256, bg Yellow 256, Underlined, Italic + sgr(NO_UNDERLINED, NO_ITALIC) + line, // fg Green 256, bg Yellow 256 + sgr(FG_RESET, ITALIC) + line, // bg Yellow 256, Italic + sgr(BG_RESET) + line, // Italic + sgr(NORMAL) + line, // Back to normal + sgr(FG_P256_RED) + line, // fg Red 256 + sgr(FG_P256_GREEN, BG_P256_YELLOW) + line, // fg Green 256, bg Yellow 256 + sgr(UNDERLINED, ITALIC) + line, // fg Green 256, bg Yellow 256, Underlined, Italic + sgr(NO_UNDERLINED, NO_ITALIC) + line, // fg Green 256, bg Yellow 256 + sgr(FG_RESET, ITALIC) + line, // bg Yellow 256, Italic + sgr(BG_RESET) + line // Italic ]; await writeSync(page, lines.join('\\r\\n')); assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n')); @@ -291,16 +289,16 @@ describe('SerializeAddon', () => { const cols = 10; const line = '+'.repeat(cols); const lines: string[] = [ - mkSGR(FG_RGB_RED) + line, // fg Red RGB, - mkSGR(UNDERLINED) + line, // fg Red RGB, Underlined - mkSGR(FG_RGB_GREEN) + line, // fg Green RGB, Underlined - mkSGR(INVERSE) + line, // fg Green RGB, Underlined, Inverse - mkSGR(NO_INVERSE) + line, // fg Green RGB, Underlined - mkSGR(INVERSE) + line, // fg Green RGB, Underlined, Inverse - mkSGR(BG_RGB_YELLOW) + line, // fg Green RGB, bg Yellow RGB, Underlined, Inverse - mkSGR(FG_RESET) + line, // bg Yellow RGB, Underlined, Inverse - mkSGR(BG_RESET) + line, // Underlined, Inverse - mkSGR(NORMAL) + line // Back to normal + sgr(FG_RGB_RED) + line, // fg Red RGB, + sgr(UNDERLINED) + line, // fg Red RGB, Underlined + sgr(FG_RGB_GREEN) + line, // fg Green RGB, Underlined + sgr(INVERSE) + line, // fg Green RGB, Underlined, Inverse + sgr(NO_INVERSE) + line, // fg Green RGB, Underlined + sgr(INVERSE) + line, // fg Green RGB, Underlined, Inverse + sgr(BG_RGB_YELLOW) + line, // fg Green RGB, bg Yellow RGB, Underlined, Inverse + sgr(FG_RESET) + line, // bg Yellow RGB, Underlined, Inverse + sgr(BG_RESET) + line, // Underlined, Inverse + sgr(NORMAL) + line // Back to normal ]; await writeSync(page, lines.join('\\r\\n')); assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n')); @@ -310,19 +308,19 @@ describe('SerializeAddon', () => { const cols = 10; const line = '+'.repeat(cols); const lines: string[] = [ - mkSGR(FG_RGB_RED) + line, // fg Red RGB - mkSGR(FG_RGB_GREEN, BG_RGB_YELLOW) + line, // fg Green RGB, bg Yellow RGB - mkSGR(UNDERLINED, ITALIC) + line, // fg Green RGB, bg Yellow RGB, Underlined, Italic - mkSGR(NO_UNDERLINED, NO_ITALIC) + line, // fg Green RGB, bg Yellow RGB - mkSGR(FG_RESET, ITALIC) + line, // bg Yellow RGB, Italic - mkSGR(BG_RESET) + line, // Italic - mkSGR(NORMAL) + line, // Back to normal - mkSGR(FG_RGB_RED) + line, // fg Red RGB - mkSGR(FG_RGB_GREEN, BG_RGB_YELLOW) + line, // fg Green RGB, bg Yellow RGB - mkSGR(UNDERLINED, ITALIC) + line, // fg Green RGB, bg Yellow RGB, Underlined, Italic - mkSGR(NO_UNDERLINED, NO_ITALIC) + line, // fg Green RGB, bg Yellow RGB - mkSGR(FG_RESET, ITALIC) + line, // bg Yellow RGB, Italic - mkSGR(BG_RESET) + line // Italic + sgr(FG_RGB_RED) + line, // fg Red RGB + sgr(FG_RGB_GREEN, BG_RGB_YELLOW) + line, // fg Green RGB, bg Yellow RGB + sgr(UNDERLINED, ITALIC) + line, // fg Green RGB, bg Yellow RGB, Underlined, Italic + sgr(NO_UNDERLINED, NO_ITALIC) + line, // fg Green RGB, bg Yellow RGB + sgr(FG_RESET, ITALIC) + line, // bg Yellow RGB, Italic + sgr(BG_RESET) + line, // Italic + sgr(NORMAL) + line, // Back to normal + sgr(FG_RGB_RED) + line, // fg Red RGB + sgr(FG_RGB_GREEN, BG_RGB_YELLOW) + line, // fg Green RGB, bg Yellow RGB + sgr(UNDERLINED, ITALIC) + line, // fg Green RGB, bg Yellow RGB, Underlined, Italic + sgr(NO_UNDERLINED, NO_ITALIC) + line, // fg Green RGB, bg Yellow RGB + sgr(FG_RESET, ITALIC) + line, // bg Yellow RGB, Italic + sgr(BG_RESET) + line // Italic ]; await writeSync(page, lines.join('\\r\\n')); assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n')); @@ -503,7 +501,7 @@ function digitsString(length: number, from: number = 0, sgr: string = ''): strin return s; } -function mkSGR(...seq: string[]): string { +function sgr(...seq: string[]): string { return `\x1b[${seq.join(';')}m`; } diff --git a/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts b/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts index 58be9a973..b55ee303d 100644 --- a/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts +++ b/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts @@ -3,7 +3,6 @@ * @license MIT */ - import { Terminal, ITerminalAddon } from 'xterm'; declare module 'xterm-addon-serialize' { @@ -21,12 +20,13 @@ declare module 'xterm-addon-serialize' { public activate(terminal: Terminal): void; /** - * Serializes terminal rows into a string that can be written back to the terminal - * to restore the state. The cursor will also be positioned to the correct cell. - * When restoring a terminal it is best to do before `Terminal.open` is called - * to avoid wasting CPU cycles rendering incomplete frames. - * @param scrollback The number of rows in scrollback buffer to serialize, starting from the bottom of the - * scrollback buffer. This defaults to the all available rows in the scrollback buffer. + * Serializes terminal rows into a string that can be written back to the terminal to restore + * the state. The cursor will also be positioned to the correct cell. When restoring a terminal + * it is best to do before `Terminal.open` is called to avoid wasting CPU cycles rendering + * incomplete frames. + * @param scrollback The number of rows in scrollback buffer to serialize, starting from the + * bottom of the scrollback buffer. This defaults to the all available rows in the scrollback + * buffer. */ public serialize(scrollback?: number): string; From 6affe68ca3504921f5e8c1d67a4c697b26c784cf Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 16 Aug 2021 14:44:39 -0700 Subject: [PATCH 088/164] Expose modes api Part of #3417 --- src/browser/Terminal.ts | 46 +++++++++++++++--------------- src/browser/TestUtils.test.ts | 4 ++- src/browser/public/Terminal.ts | 23 ++++++++++++++- src/common/CoreTerminal.ts | 22 +++++++------- src/common/Types.d.ts | 4 ++- typings/xterm.d.ts | 52 ++++++++++++++++++++++++++++++++++ 6 files changed, 114 insertions(+), 37 deletions(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 004f23147..cc6498bd8 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -267,8 +267,8 @@ export class Terminal extends CoreTerminal implements ITerminal { * Binds the desired focus behavior on a given terminal object. */ private _onTextAreaFocus(ev: KeyboardEvent): void { - if (this._coreService.decPrivateModes.sendFocus) { - this._coreService.triggerDataEvent(C0.ESC + '[I'); + if (this.coreService.decPrivateModes.sendFocus) { + this.coreService.triggerDataEvent(C0.ESC + '[I'); } this.updateCursorStyle(ev); this.element!.classList.add('focus'); @@ -292,8 +292,8 @@ export class Terminal extends CoreTerminal implements ITerminal { // screen readers reading it out. this.textarea!.value = ''; this.refresh(this.buffer.y, this.buffer.y); - if (this._coreService.decPrivateModes.sendFocus) { - this._coreService.triggerDataEvent(C0.ESC + '[O'); + if (this.coreService.decPrivateModes.sendFocus) { + this.coreService.triggerDataEvent(C0.ESC + '[O'); } this.element!.classList.remove('focus'); this._onBlur.fire(); @@ -340,7 +340,7 @@ export class Terminal extends CoreTerminal implements ITerminal { } copyHandler(event, this._selectionService!); })); - const pasteHandlerWrapper = (event: ClipboardEvent): void => handlePasteEvent(event, this.textarea!, this._coreService); + const pasteHandlerWrapper = (event: ClipboardEvent): void => handlePasteEvent(event, this.textarea!, this.coreService); this.register(addDisposableDomListener(this.textarea!, 'paste', pasteHandlerWrapper)); this.register(addDisposableDomListener(this.element!, 'paste', pasteHandlerWrapper)); @@ -526,7 +526,7 @@ export class Terminal extends CoreTerminal implements ITerminal { this.register(addDisposableDomListener(this.element, 'mousedown', (e: MouseEvent) => this._selectionService!.onMouseDown(e))); // apply mouse event classes set by escape codes before terminal was attached - if (this._coreMouseService.areMouseEventsActive) { + if (this.coreMouseService.areMouseEventsActive) { this._selectionService.disable(); this.element.classList.add('enable-mouse-events'); } else { @@ -644,7 +644,7 @@ export class Terminal extends CoreTerminal implements ITerminal { return false; } - return self._coreMouseService.triggerMouseEvent({ + return self.coreMouseService.triggerMouseEvent({ col: pos.x - 33, // FIXME: why -33 here? row: pos.y - 33, button: but, @@ -699,11 +699,11 @@ export class Terminal extends CoreTerminal implements ITerminal { } } }; - this.register(this._coreMouseService.onProtocolChange(events => { + this.register(this.coreMouseService.onProtocolChange(events => { // apply global changes on events if (events) { if (this.optionsService.options.logLevel === 'debug') { - this._logService.debug('Binding to mouse events:', this._coreMouseService.explainEvents(events)); + this._logService.debug('Binding to mouse events:', this.coreMouseService.explainEvents(events)); } this.element!.classList.add('enable-mouse-events'); this._selectionService!.disable(); @@ -746,7 +746,7 @@ export class Terminal extends CoreTerminal implements ITerminal { } })); // force initial onProtocolChange so we dont miss early mouse requests - this._coreMouseService.activeProtocol = this._coreMouseService.activeProtocol; + this.coreMouseService.activeProtocol = this.coreMouseService.activeProtocol; /** * "Always on" event listeners. @@ -758,7 +758,7 @@ export class Terminal extends CoreTerminal implements ITerminal { // Don't send the mouse button to the pty if mouse events are disabled or // if the selection manager is having selection forced (ie. a modifier is // held). - if (!this._coreMouseService.areMouseEventsActive || this._selectionService!.shouldForceSelection(ev)) { + if (!this.coreMouseService.areMouseEventsActive || this._selectionService!.shouldForceSelection(ev)) { return; } @@ -791,12 +791,12 @@ export class Terminal extends CoreTerminal implements ITerminal { } // Construct and send sequences - const sequence = C0.ESC + (this._coreService.decPrivateModes.applicationCursorKeys ? 'O' : '[') + (ev.deltaY < 0 ? 'A' : 'B'); + const sequence = C0.ESC + (this.coreService.decPrivateModes.applicationCursorKeys ? 'O' : '[') + (ev.deltaY < 0 ? 'A' : 'B'); let data = ''; for (let i = 0; i < Math.abs(amount); i++) { data += sequence; } - this._coreService.triggerDataEvent(data, true); + this.coreService.triggerDataEvent(data, true); } return; } @@ -812,13 +812,13 @@ export class Terminal extends CoreTerminal implements ITerminal { }, { passive: false })); this.register(addDisposableDomListener(el, 'touchstart', (ev: TouchEvent) => { - if (this._coreMouseService.areMouseEventsActive) return; + if (this.coreMouseService.areMouseEventsActive) return; this.viewport!.onTouchStart(ev); return this.cancel(ev); }, { passive: true })); this.register(addDisposableDomListener(el, 'touchmove', (ev: TouchEvent) => { - if (this._coreMouseService.areMouseEventsActive) return; + if (this.coreMouseService.areMouseEventsActive) return; if (!this.viewport!.onTouchMove(ev)) { return this.cancel(ev); } @@ -860,8 +860,8 @@ export class Terminal extends CoreTerminal implements ITerminal { * Display the cursor element */ private _showCursor(): void { - if (!this._coreService.isCursorInitialized) { - this._coreService.isCursorInitialized = true; + if (!this.coreService.isCursorInitialized) { + this.coreService.isCursorInitialized = true; this.refresh(this.buffer.y, this.buffer.y); } } @@ -872,7 +872,7 @@ export class Terminal extends CoreTerminal implements ITerminal { } public paste(data: string): void { - paste(data, this.textarea!, this._coreService); + paste(data, this.textarea!, this.coreService); } /** @@ -1025,7 +1025,7 @@ export class Terminal extends CoreTerminal implements ITerminal { return false; } - const result = evaluateKeyboardEvent(event, this._coreService.decPrivateModes.applicationCursorKeys, this.browser.isMac, this.options.macOptionIsMeta); + const result = evaluateKeyboardEvent(event, this.coreService.decPrivateModes.applicationCursorKeys, this.browser.isMac, this.options.macOptionIsMeta); this.updateCursorStyle(event); @@ -1061,7 +1061,7 @@ export class Terminal extends CoreTerminal implements ITerminal { this._onKey.fire({ key: result.key, domEvent: event }); this._showCursor(); - this._coreService.triggerDataEvent(result.key, true); + this.coreService.triggerDataEvent(result.key, true); // Cancel events when not in screen reader mode so events don't get bubbled up and handled by // other listeners. When screen reader mode is enabled, this could cause issues if the event @@ -1138,7 +1138,7 @@ export class Terminal extends CoreTerminal implements ITerminal { this._onKey.fire({ key, domEvent: ev }); this._showCursor(); - this._coreService.triggerDataEvent(key, true); + this.coreService.triggerDataEvent(key, true); return true; } @@ -1247,12 +1247,12 @@ export class Terminal extends CoreTerminal implements ITerminal { case WindowsOptionsReportType.GET_WIN_SIZE_PIXELS: const canvasWidth = this._renderService.dimensions.scaledCanvasWidth.toFixed(0); const canvasHeight = this._renderService.dimensions.scaledCanvasHeight.toFixed(0); - this._coreService.triggerDataEvent(`${C0.ESC}[4;${canvasHeight};${canvasWidth}t`); + this.coreService.triggerDataEvent(`${C0.ESC}[4;${canvasHeight};${canvasWidth}t`); break; case WindowsOptionsReportType.GET_CELL_SIZE_PIXELS: const cellWidth = this._renderService.dimensions.scaledCellWidth.toFixed(0); const cellHeight = this._renderService.dimensions.scaledCellHeight.toFixed(0); - this._coreService.triggerDataEvent(`${C0.ESC}[6;${cellHeight};${cellWidth}t`); + this.coreService.triggerDataEvent(`${C0.ESC}[6;${cellHeight};${cellWidth}t`); break; } } diff --git a/src/browser/TestUtils.test.ts b/src/browser/TestUtils.test.ts index 9d5373c8a..daa6843c3 100644 --- a/src/browser/TestUtils.test.ts +++ b/src/browser/TestUtils.test.ts @@ -13,7 +13,7 @@ import { IBufferLine, ICellData, IAttributeData, ICircularList, XtermListener, I import { Buffer } from 'common/buffer/Buffer'; import * as Browser from 'common/Platform'; import { Terminal } from 'browser/Terminal'; -import { IUnicodeService, IOptionsService } from 'common/services/Services'; +import { IUnicodeService, IOptionsService, ICoreService, ICoreMouseService } from 'common/services/Services'; import { IFunctionIdentifier, IParams } from 'common/parser/Types'; import { AttributeData } from 'common/buffer/AttributeData'; @@ -43,6 +43,8 @@ export class MockTerminal implements ITerminal { public onRender!: IEvent<{ start: number, end: number }>; public onResize!: IEvent<{ cols: number, rows: number }>; public markers!: IMarker[]; + public coreMouseService!: ICoreMouseService; + public coreService!: ICoreService; public optionsService!: IOptionsService; public unicodeService!: IUnicodeService; public addMarker(cursorYOffset: number): IMarker { diff --git a/src/browser/public/Terminal.ts b/src/browser/public/Terminal.ts index 6af9db71e..a76b1a229 100644 --- a/src/browser/public/Terminal.ts +++ b/src/browser/public/Terminal.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBufferNamespace as IBufferNamespaceApi, IParser, ILinkProvider, IUnicodeHandling, FontWeight } from 'xterm'; +import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBufferNamespace as IBufferNamespaceApi, IParser, ILinkProvider, IUnicodeHandling, FontWeight, IModes } from 'xterm'; import { ITerminal } from 'browser/Types'; import { Terminal as TerminalCore } from 'browser/Terminal'; import * as Strings from 'browser/LocalizableStrings'; @@ -68,6 +68,27 @@ export class Terminal implements ITerminalApi { 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 blur(): void { this._core.blur(); } diff --git a/src/common/CoreTerminal.ts b/src/common/CoreTerminal.ts index e61a8e16e..96a4b53dd 100644 --- a/src/common/CoreTerminal.ts +++ b/src/common/CoreTerminal.ts @@ -47,11 +47,11 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { protected readonly _instantiationService: IInstantiationService; protected readonly _bufferService: IBufferService; protected readonly _logService: ILogService; - protected readonly _coreService: ICoreService; protected readonly _charsetService: ICharsetService; - protected readonly _coreMouseService: ICoreMouseService; protected readonly _dirtyRowService: IDirtyRowService; + public readonly coreMouseService: ICoreMouseService; + public readonly coreService: ICoreService; public readonly unicodeService: IUnicodeService; public readonly optionsService: IOptionsService; @@ -100,10 +100,10 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { this._instantiationService.setService(IBufferService, this._bufferService); this._logService = this._instantiationService.createInstance(LogService); this._instantiationService.setService(ILogService, this._logService); - this._coreService = this.register(this._instantiationService.createInstance(CoreService, () => this.scrollToBottom())); - this._instantiationService.setService(ICoreService, this._coreService); - this._coreMouseService = this._instantiationService.createInstance(CoreMouseService); - this._instantiationService.setService(ICoreMouseService, this._coreMouseService); + this.coreService = this.register(this._instantiationService.createInstance(CoreService, () => this.scrollToBottom())); + this._instantiationService.setService(ICoreService, this.coreService); + this.coreMouseService = this._instantiationService.createInstance(CoreMouseService); + this._instantiationService.setService(ICoreMouseService, this.coreMouseService); this._dirtyRowService = this._instantiationService.createInstance(DirtyRowService); this._instantiationService.setService(IDirtyRowService, this._dirtyRowService); this.unicodeService = this._instantiationService.createInstance(UnicodeService); @@ -112,14 +112,14 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { this._instantiationService.setService(ICharsetService, this._charsetService); // Register input handler and handle/forward events - this._inputHandler = new InputHandler(this._bufferService, this._charsetService, this._coreService, this._dirtyRowService, this._logService, this.optionsService, this._coreMouseService, this.unicodeService); + this._inputHandler = new InputHandler(this._bufferService, this._charsetService, this.coreService, this._dirtyRowService, this._logService, this.optionsService, this.coreMouseService, this.unicodeService); this.register(forwardEvent(this._inputHandler.onLineFeed, this._onLineFeed)); this.register(this._inputHandler); // Setup listeners this.register(forwardEvent(this._bufferService.onResize, this._onResize)); - this.register(forwardEvent(this._coreService.onData, this._onData)); - this.register(forwardEvent(this._coreService.onBinary, this._onBinary)); + this.register(forwardEvent(this.coreService.onData, this._onData)); + this.register(forwardEvent(this.coreService.onBinary, this._onBinary)); this.register(this.optionsService.onOptionChange(key => this._updateOptions(key))); this.register(this._bufferService.onScroll(event => { this._onScroll.fire({ position: this._bufferService.buffer.ydisp, source: ScrollSource.TERMINAL }); @@ -250,8 +250,8 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal { this._inputHandler.reset(); this._bufferService.reset(); this._charsetService.reset(); - this._coreService.reset(); - this._coreMouseService.reset(); + this.coreService.reset(); + this.coreMouseService.reset(); } protected _updateOptions(key: string): void { diff --git a/src/common/Types.d.ts b/src/common/Types.d.ts index 36f75dd0e..78e2e62d1 100644 --- a/src/common/Types.d.ts +++ b/src/common/Types.d.ts @@ -7,10 +7,12 @@ import { IFunctionIdentifier, ITerminalOptions as IPublicTerminalOptions } from import { IEvent, IEventEmitter } from 'common/EventEmitter'; import { IDeleteEvent, IInsertEvent } from 'common/CircularList'; import { IParams } from 'common/parser/Types'; -import { IOptionsService, IUnicodeService } from 'common/services/Services'; +import { ICoreMouseService, ICoreService, IOptionsService, IUnicodeService } from 'common/services/Services'; import { IBufferSet } from 'common/buffer/Types'; export interface ICoreTerminal { + coreMouseService: ICoreMouseService; + coreService: ICoreService; optionsService: IOptionsService; unicodeService: IUnicodeService; buffers: IBufferSet; diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 035748fcb..210e354d9 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -622,6 +622,11 @@ declare module 'xterm' { */ readonly unicode: IUnicodeHandling; + /** + * Gets the terminal modes as set by SM/DECSET. + */ + readonly modes: IModes; + /** * Natural language strings that can be localized. */ @@ -1622,4 +1627,51 @@ declare module 'xterm' { */ activeVersion: string; } + + /** + * Terminal modes as set by SM/DECSET. + */ + export interface IModes { + /** + * Application Cursor Keys (DECCKM): `CSI ? 1 h` + */ + readonly applicationCursorKeysMode: boolean; + /** + * Application Keypad Mode (DECNKM): `CSI ? 6 6 h` + */ + readonly applicationKeypadMode: boolean; + /** + * Bracketed Paste Mode: `CSI ? 2 0 0 4 h` + */ + readonly bracketedPasteMode: boolean; + /** + * Insert Mode (IRM): `CSI 4 h` + */ + readonly insertMode: boolean; + /** + * Mouse Tracking, this can be one of the following: + * - none: This is the default value and can be reset with DECRST + * - x10: Send Mouse X & Y on button press `CSI ? 9 h` + * - vt200: Send Mouse X & Y on button press and release `CSI ? 1 0 0 0 h` + * - drag: Use Cell Motion Mouse Tracking `CSI ? 1 0 0 2 h` + * - any: Use All Motion Mouse Tracking `CSI ? 1 0 0 3 h` + */ + readonly mouseTrackingMode: 'none' | 'x10' | 'vt200' | 'drag' | 'any'; + /** + * Origin Mode (DECOM): `CSI ? 6 h` + */ + readonly originMode: boolean; + /** + * Reverse-wraparound Mode: `CSI ? 4 5 h` + */ + readonly reverseWraparoundMode: boolean; + /** + * Send FocusIn/FocusOut events: `CSI ? 1 0 0 3 h` + */ + readonly sendFocusMode: boolean; + /** + * Auto-Wrap Mode (DECAWM): `CSI ? 7 h` + */ + readonly wraparoundMode: boolean + } } From 8c25d57c260f275e3eb1c7e1890a647668d1a7a8 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 16 Aug 2021 15:01:30 -0700 Subject: [PATCH 089/164] xterm-headless modes api, tests for headless --- src/headless/public/Terminal.test.ts | 82 + src/headless/public/Terminal.ts | 23 +- typings/xterm-headless.d.ts | 2388 +++++++++++++------------- typings/xterm.d.ts | 2 +- 4 files changed, 1325 insertions(+), 1170 deletions(-) diff --git a/src/headless/public/Terminal.test.ts b/src/headless/public/Terminal.test.ts index 15e1efbac..4247aae9e 100644 --- a/src/headless/public/Terminal.test.ts +++ b/src/headless/public/Terminal.test.ts @@ -367,6 +367,88 @@ describe('Headless API Tests', function(): void { }); }); + describe('modes', () => { + it('defaults', () => { + deepStrictEqual(term.modes, { + applicationCursorKeysMode: false, + applicationKeypadMode: false, + bracketedPasteMode: false, + insertMode: false, + mouseTrackingMode: 'none', + originMode: false, + reverseWraparoundMode: false, + sendFocusMode: false, + wraparoundMode: true + }); + }); + it('applicationCursorKeysMode', async () => { + await writeSync('\x1b[?1h'); + strictEqual(term.modes.applicationCursorKeysMode, true); + await writeSync('\x1b[?1l'); + strictEqual(term.modes.applicationCursorKeysMode, false); + }); + it('applicationKeypadMode', async () => { + await writeSync('\x1b[?66h'); + strictEqual(term.modes.applicationKeypadMode, true); + await writeSync('\x1b[?66l'); + strictEqual(term.modes.applicationKeypadMode, false); + }); + it('bracketedPasteMode', async () => { + await writeSync('\x1b[?2004h'); + strictEqual(term.modes.bracketedPasteMode, true); + await writeSync('\x1b[?2004l'); + strictEqual(term.modes.bracketedPasteMode, false); + }); + it('insertMode', async () => { + await writeSync('\x1b[4h'); + strictEqual(term.modes.insertMode, true); + await writeSync('\x1b[4l'); + strictEqual(term.modes.insertMode, false); + }); + it('mouseTrackingMode', async () => { + await writeSync('\x1b[?9h'); + strictEqual(term.modes.mouseTrackingMode, 'x10'); + await writeSync('\x1b[?9l'); + strictEqual(term.modes.mouseTrackingMode, 'none'); + await writeSync('\x1b[?1000h'); + strictEqual(term.modes.mouseTrackingMode, 'vt200'); + await writeSync('\x1b[?1000l'); + strictEqual(term.modes.mouseTrackingMode, 'none'); + await writeSync('\x1b[?1002h'); + strictEqual(term.modes.mouseTrackingMode, 'drag'); + await writeSync('\x1b[?1002l'); + strictEqual(term.modes.mouseTrackingMode, 'none'); + await writeSync('\x1b[?1003h'); + strictEqual(term.modes.mouseTrackingMode, 'any'); + await writeSync('\x1b[?1003l'); + strictEqual(term.modes.mouseTrackingMode, 'none'); + }); + it('originMode', async () => { + await writeSync('\x1b[?6h'); + strictEqual(term.modes.originMode, true); + await writeSync('\x1b[?6l'); + strictEqual(term.modes.originMode, false); + }); + it('reverseWraparoundMode', async () => { + await writeSync('\x1b[?45h'); + strictEqual(term.modes.reverseWraparoundMode, true); + await writeSync('\x1b[?45l'); + strictEqual(term.modes.reverseWraparoundMode, false); + }); + it('sendFocusMode', async () => { + await writeSync('\x1b[?1004h'); + strictEqual(term.modes.sendFocusMode, true); + await writeSync('\x1b[?1004l'); + strictEqual(term.modes.sendFocusMode, false); + }); + it('wraparoundMode', async () => { + await writeSync('\x1b[?7h'); + strictEqual(term.modes.wraparoundMode, true); + await writeSync('\x1b[?7l'); + strictEqual(term.modes.wraparoundMode, false); + }); + }); + it('dispose', async () => { term.dispose(); strictEqual((term as any)._core._isDisposed, true); diff --git a/src/headless/public/Terminal.ts b/src/headless/public/Terminal.ts index a1de7fdb1..29e835810 100644 --- a/src/headless/public/Terminal.ts +++ b/src/headless/public/Terminal.ts @@ -7,7 +7,7 @@ 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, IParser, ITerminalAddon, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-headless'; +import { IBufferNamespace as IBufferNamespaceApi, IMarker, IModes, IParser, ITerminalAddon, ITerminalOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-headless'; import { Terminal as TerminalCore } from 'headless/Terminal'; import { AddonManager } from 'common/public/AddonManager'; @@ -61,6 +61,27 @@ export class Terminal implements ITerminalApi { 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 resize(columns: number, rows: number): void { this._verifyIntegers(columns, rows); this._core.resize(columns, rows); diff --git a/typings/xterm-headless.d.ts b/typings/xterm-headless.d.ts index 03e7567a7..b6e1505b1 100644 --- a/typings/xterm-headless.d.ts +++ b/typings/xterm-headless.d.ts @@ -8,1246 +8,1298 @@ */ declare module 'xterm-headless' { + /** + * A string representing log level. + */ + export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off'; + + /** + * An object containing start up options for the terminal. + */ + export interface ITerminalOptions { /** - * A string representing log level. + * Whether to allow the use of proposed API. When false, any usage of APIs + * marked as experimental/proposed will throw an error. This defaults to + * true currently, but will change to false in v5.0. */ - export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off'; + allowProposedApi?: boolean; /** - * An object containing start up options for the terminal. + * Whether background should support non-opaque color. It must be set before + * executing the `Terminal.open()` method and can't be changed later without + * executing it again. Note that enabling this can negatively impact + * performance. */ - export interface ITerminalOptions { - /** - * Whether to allow the use of proposed API. When false, any usage of APIs - * marked as experimental/proposed will throw an error. This defaults to - * true currently, but will change to false in v5.0. - */ - allowProposedApi?: boolean; - - /** - * Whether background should support non-opaque color. It must be set before - * executing the `Terminal.open()` method and can't be changed later without - * executing it again. Note that enabling this can negatively impact - * performance. - */ - allowTransparency?: boolean; - - /** - * If enabled, alt + click will move the prompt cursor to position - * underneath the mouse. The default is true. - */ - altClickMovesCursor?: boolean; - - /** - * A data uri of the sound to use for the bell when `bellStyle = 'sound'`. - */ - bellSound?: string; - - /** - * The type of the bell notification the terminal will use. - */ - bellStyle?: 'none' | 'sound'; - - /** - * When enabled the cursor will be set to the beginning of the next line - * with every new line. This is equivalent to sending '\r\n' for each '\n'. - * Normally the termios settings of the underlying PTY deals with the - * translation of '\n' to '\r\n' and this setting should not be used. If you - * deal with data from a non-PTY related source, this settings might be - * useful. - */ - convertEol?: boolean; - - /** - * The number of columns in the terminal. - */ - cols?: number; - - /** - * Whether the cursor blinks. - */ - cursorBlink?: boolean; - - /** - * The style of the cursor. - */ - cursorStyle?: 'block' | 'underline' | 'bar'; - - /** - * The width of the cursor in CSS pixels when `cursorStyle` is set to 'bar'. - */ - cursorWidth?: number; - - /** - * Whether input should be disabled. - */ - disableStdin?: boolean; - - /** - * Whether to draw bold text in bright colors. The default is true. - */ - drawBoldTextInBrightColors?: boolean; - - /** - * The modifier key hold to multiply scroll speed. - */ - fastScrollModifier?: 'alt' | 'ctrl' | 'shift' | undefined; - - /** - * The spacing in whole pixels between characters. - */ - letterSpacing?: number; - - /** - * The line height used to render text. - */ - lineHeight?: number; - - /** - * The duration in milliseconds before link tooltip events fire when - * hovering on a link. - * @deprecated This will be removed when the link matcher API is removed. - */ - linkTooltipHoverDuration?: number; - - /** - * What log level to use, this will log for all levels below and including - * what is set: - * - * 1. debug - * 2. info (default) - * 3. warn - * 4. error - * 5. off - */ - logLevel?: LogLevel; - - /** - * Whether to treat option as the meta key. - */ - macOptionIsMeta?: boolean; - - /** - * Whether holding a modifier key will force normal selection behavior, - * regardless of whether the terminal is in mouse events mode. This will - * also prevent mouse events from being emitted by the terminal. For - * example, this allows you to use xterm.js' regular selection inside tmux - * with mouse mode enabled. - */ - macOptionClickForcesSelection?: boolean; - - /** - * The minimum contrast ratio for text in the terminal, setting this will - * change the foreground color dynamically depending on whether the contrast - * ratio is met. Example values: - * - * - 1: The default, do nothing. - * - 4.5: Minimum for WCAG AA compliance. - * - 7: Minimum for WCAG AAA compliance. - * - 21: White on black or black on white. - */ - minimumContrastRatio?: number; - - /** - * Whether to select the word under the cursor on right click, this is - * standard behavior in a lot of macOS applications. - */ - rightClickSelectsWord?: boolean; - - /** - * The number of rows in the terminal. - */ - rows?: number; - - /** - * Whether screen reader support is enabled. When on this will expose - * supporting elements in the DOM to support NVDA on Windows and VoiceOver - * on macOS. - */ - screenReaderMode?: boolean; - - /** - * The amount of scrollback in the terminal. Scrollback is the amount of - * rows that are retained when lines are scrolled beyond the initial - * viewport. - */ - scrollback?: number; - - /** - * The scrolling speed multiplier used for adjusting normal scrolling speed. - */ - scrollSensitivity?: number; - - /** - * The size of tab stops in the terminal. - */ - tabStopWidth?: number; - - /** - * The color theme of the terminal. - */ - theme?: ITheme; - - /** - * Whether "Windows mode" is enabled. Because Windows backends winpty and - * conpty operate by doing line wrapping on their side, xterm.js does not - * have access to wrapped lines. When Windows mode is enabled the following - * changes will be in effect: - * - * - Reflow is disabled. - * - Lines are assumed to be wrapped if the last character of the line is - * not whitespace. - */ - windowsMode?: boolean; - - /** - * A string containing all characters that are considered word separated by the - * double click to select work logic. - */ - wordSeparator?: string; - - /** - * Enable various window manipulation and report features. - * All features are disabled by default for security reasons. - */ - windowOptions?: IWindowOptions; - } + allowTransparency?: boolean; /** - * Contains colors to theme the terminal with. + * If enabled, alt + click will move the prompt cursor to position + * underneath the mouse. The default is true. */ - export interface ITheme { - /** The default foreground color */ - foreground?: string; - /** The default background color */ - background?: string; - /** The cursor color */ - cursor?: string; - /** The accent color of the cursor (fg color for a block cursor) */ - cursorAccent?: string; - /** The selection background color (can be transparent) */ - selection?: string; - /** ANSI black (eg. `\x1b[30m`) */ - black?: string; - /** ANSI red (eg. `\x1b[31m`) */ - red?: string; - /** ANSI green (eg. `\x1b[32m`) */ - green?: string; - /** ANSI yellow (eg. `\x1b[33m`) */ - yellow?: string; - /** ANSI blue (eg. `\x1b[34m`) */ - blue?: string; - /** ANSI magenta (eg. `\x1b[35m`) */ - magenta?: string; - /** ANSI cyan (eg. `\x1b[36m`) */ - cyan?: string; - /** ANSI white (eg. `\x1b[37m`) */ - white?: string; - /** ANSI bright black (eg. `\x1b[1;30m`) */ - brightBlack?: string; - /** ANSI bright red (eg. `\x1b[1;31m`) */ - brightRed?: string; - /** ANSI bright green (eg. `\x1b[1;32m`) */ - brightGreen?: string; - /** ANSI bright yellow (eg. `\x1b[1;33m`) */ - brightYellow?: string; - /** ANSI bright blue (eg. `\x1b[1;34m`) */ - brightBlue?: string; - /** ANSI bright magenta (eg. `\x1b[1;35m`) */ - brightMagenta?: string; - /** ANSI bright cyan (eg. `\x1b[1;36m`) */ - brightCyan?: string; - /** ANSI bright white (eg. `\x1b[1;37m`) */ - brightWhite?: string; - } + altClickMovesCursor?: boolean; /** - * An object that can be disposed via a dispose function. + * A data uri of the sound to use for the bell when `bellStyle = 'sound'`. */ - export interface IDisposable { - dispose(): void; - } + bellSound?: string; /** - * An event that can be listened to. + * The type of the bell notification the terminal will use. + */ + bellStyle?: 'none' | 'sound'; + + /** + * When enabled the cursor will be set to the beginning of the next line + * with every new line. This is equivalent to sending '\r\n' for each '\n'. + * Normally the termios settings of the underlying PTY deals with the + * translation of '\n' to '\r\n' and this setting should not be used. If you + * deal with data from a non-PTY related source, this settings might be + * useful. + */ + convertEol?: boolean; + + /** + * The number of columns in the terminal. + */ + cols?: number; + + /** + * Whether the cursor blinks. + */ + cursorBlink?: boolean; + + /** + * The style of the cursor. + */ + cursorStyle?: 'block' | 'underline' | 'bar'; + + /** + * The width of the cursor in CSS pixels when `cursorStyle` is set to 'bar'. + */ + cursorWidth?: number; + + /** + * Whether input should be disabled. + */ + disableStdin?: boolean; + + /** + * Whether to draw bold text in bright colors. The default is true. + */ + drawBoldTextInBrightColors?: boolean; + + /** + * The modifier key hold to multiply scroll speed. + */ + fastScrollModifier?: 'alt' | 'ctrl' | 'shift' | undefined; + + /** + * The spacing in whole pixels between characters. + */ + letterSpacing?: number; + + /** + * The line height used to render text. + */ + lineHeight?: number; + + /** + * The duration in milliseconds before link tooltip events fire when + * hovering on a link. + * @deprecated This will be removed when the link matcher API is removed. + */ + linkTooltipHoverDuration?: number; + + /** + * What log level to use, this will log for all levels below and including + * what is set: + * + * 1. debug + * 2. info (default) + * 3. warn + * 4. error + * 5. off + */ + logLevel?: LogLevel; + + /** + * Whether to treat option as the meta key. + */ + macOptionIsMeta?: boolean; + + /** + * Whether holding a modifier key will force normal selection behavior, + * regardless of whether the terminal is in mouse events mode. This will + * also prevent mouse events from being emitted by the terminal. For + * example, this allows you to use xterm.js' regular selection inside tmux + * with mouse mode enabled. + */ + macOptionClickForcesSelection?: boolean; + + /** + * The minimum contrast ratio for text in the terminal, setting this will + * change the foreground color dynamically depending on whether the contrast + * ratio is met. Example values: + * + * - 1: The default, do nothing. + * - 4.5: Minimum for WCAG AA compliance. + * - 7: Minimum for WCAG AAA compliance. + * - 21: White on black or black on white. + */ + minimumContrastRatio?: number; + + /** + * Whether to select the word under the cursor on right click, this is + * standard behavior in a lot of macOS applications. + */ + rightClickSelectsWord?: boolean; + + /** + * The number of rows in the terminal. + */ + rows?: number; + + /** + * Whether screen reader support is enabled. When on this will expose + * supporting elements in the DOM to support NVDA on Windows and VoiceOver + * on macOS. + */ + screenReaderMode?: boolean; + + /** + * The amount of scrollback in the terminal. Scrollback is the amount of + * rows that are retained when lines are scrolled beyond the initial + * viewport. + */ + scrollback?: number; + + /** + * The scrolling speed multiplier used for adjusting normal scrolling speed. + */ + scrollSensitivity?: number; + + /** + * The size of tab stops in the terminal. + */ + tabStopWidth?: number; + + /** + * The color theme of the terminal. + */ + theme?: ITheme; + + /** + * Whether "Windows mode" is enabled. Because Windows backends winpty and + * conpty operate by doing line wrapping on their side, xterm.js does not + * have access to wrapped lines. When Windows mode is enabled the following + * changes will be in effect: + * + * - Reflow is disabled. + * - Lines are assumed to be wrapped if the last character of the line is + * not whitespace. + */ + windowsMode?: boolean; + + /** + * A string containing all characters that are considered word separated by the + * double click to select work logic. + */ + wordSeparator?: string; + + /** + * Enable various window manipulation and report features. + * All features are disabled by default for security reasons. + */ + windowOptions?: IWindowOptions; + } + + /** + * Contains colors to theme the terminal with. + */ + export interface ITheme { + /** The default foreground color */ + foreground?: string; + /** The default background color */ + background?: string; + /** The cursor color */ + cursor?: string; + /** The accent color of the cursor (fg color for a block cursor) */ + cursorAccent?: string; + /** The selection background color (can be transparent) */ + selection?: string; + /** ANSI black (eg. `\x1b[30m`) */ + black?: string; + /** ANSI red (eg. `\x1b[31m`) */ + red?: string; + /** ANSI green (eg. `\x1b[32m`) */ + green?: string; + /** ANSI yellow (eg. `\x1b[33m`) */ + yellow?: string; + /** ANSI blue (eg. `\x1b[34m`) */ + blue?: string; + /** ANSI magenta (eg. `\x1b[35m`) */ + magenta?: string; + /** ANSI cyan (eg. `\x1b[36m`) */ + cyan?: string; + /** ANSI white (eg. `\x1b[37m`) */ + white?: string; + /** ANSI bright black (eg. `\x1b[1;30m`) */ + brightBlack?: string; + /** ANSI bright red (eg. `\x1b[1;31m`) */ + brightRed?: string; + /** ANSI bright green (eg. `\x1b[1;32m`) */ + brightGreen?: string; + /** ANSI bright yellow (eg. `\x1b[1;33m`) */ + brightYellow?: string; + /** ANSI bright blue (eg. `\x1b[1;34m`) */ + brightBlue?: string; + /** ANSI bright magenta (eg. `\x1b[1;35m`) */ + brightMagenta?: string; + /** ANSI bright cyan (eg. `\x1b[1;36m`) */ + brightCyan?: string; + /** ANSI bright white (eg. `\x1b[1;37m`) */ + brightWhite?: string; + } + + /** + * An object that can be disposed via a dispose function. + */ + export interface IDisposable { + dispose(): void; + } + + /** + * An event that can be listened to. + * @returns an `IDisposable` to stop listening. + */ + export interface IEvent { + (listener: (arg1: T, arg2: U) => any): IDisposable; + } + + /** + * Represents a specific line in the terminal that is tracked when scrollback + * is trimmed and lines are added or removed. This is a single line that may + * be part of a larger wrapped line. + */ + export interface IMarker extends IDisposable { + /** + * A unique identifier for this marker. + */ + readonly id: number; + + /** + * Whether this marker is disposed. + */ + readonly isDisposed: boolean; + + /** + * The actual line index in the buffer at this point in time. This is set to + * -1 if the marker has been disposed. + */ + readonly line: number; + + /** + * Event listener to get notified when the marker gets disposed. Automatic disposal + * might happen for a marker, that got invalidated by scrolling out or removal of + * a line from the buffer. + */ + onDispose: IEvent; + } + + /** + * The set of localizable strings. + */ + export interface ILocalizableStrings { + /** + * The aria label for the underlying input textarea for the terminal. + */ + promptLabel: string; + + /** + * Announcement for when line reading is suppressed due to too many lines + * being printed to the terminal when `screenReaderMode` is enabled. + */ + tooMuchOutput: string; + } + + /** + * Enable various window manipulation and report features (CSI Ps ; Ps ; Ps t). + * + * Most settings have no default implementation, as they heavily rely on + * the embedding environment. + * + * To implement a feature, create a custom CSI hook like this: + * ```ts + * term.parser.addCsiHandler({final: 't'}, params => { + * const ps = params[0]; + * switch (ps) { + * case XY: + * ... // your implementation for option XY + * return true; // signal Ps=XY was handled + * } + * return false; // any Ps that was not handled + * }); + * ``` + * + * Note on security: + * Most features are meant to deal with some information of the host machine + * where the terminal runs on. This is seen as a security risk possibly leaking + * sensitive data of the host to the program in the terminal. Therefore all options + * (even those without a default implementation) are guarded by the boolean flag + * and disabled by default. + */ + export interface IWindowOptions { + /** + * Ps=1 De-iconify window. + * No default implementation. + */ + restoreWin?: boolean; + /** + * Ps=2 Iconify window. + * No default implementation. + */ + minimizeWin?: boolean; + /** + * Ps=3 ; x ; y + * Move window to [x, y]. + * No default implementation. + */ + setWinPosition?: boolean; + /** + * Ps = 4 ; height ; width + * Resize the window to given `height` and `width` in pixels. + * Omitted parameters should reuse the current height or width. + * Zero parameters should use the display's height or width. + * No default implementation. + */ + setWinSizePixels?: boolean; + /** + * Ps=5 Raise the window to the front of the stacking order. + * No default implementation. + */ + raiseWin?: boolean; + /** + * Ps=6 Lower the xterm window to the bottom of the stacking order. + * No default implementation. + */ + lowerWin?: boolean; + /** Ps=7 Refresh the window. */ + refreshWin?: boolean; + /** + * Ps = 8 ; height ; width + * Resize the text area to given height and width in characters. + * Omitted parameters should reuse the current height or width. + * Zero parameters use the display's height or width. + * No default implementation. + */ + setWinSizeChars?: boolean; + /** + * Ps=9 ; 0 Restore maximized window. + * Ps=9 ; 1 Maximize window (i.e., resize to screen size). + * Ps=9 ; 2 Maximize window vertically. + * Ps=9 ; 3 Maximize window horizontally. + * No default implementation. + */ + maximizeWin?: boolean; + /** + * Ps=10 ; 0 Undo full-screen mode. + * Ps=10 ; 1 Change to full-screen. + * Ps=10 ; 2 Toggle full-screen. + * No default implementation. + */ + fullscreenWin?: boolean; + /** Ps=11 Report xterm window state. + * If the xterm window is non-iconified, it returns "CSI 1 t". + * If the xterm window is iconified, it returns "CSI 2 t". + * No default implementation. + */ + getWinState?: boolean; + /** + * Ps=13 Report xterm window position. Result is "CSI 3 ; x ; y t". + * Ps=13 ; 2 Report xterm text-area position. Result is "CSI 3 ; x ; y t". + * No default implementation. + */ + getWinPosition?: boolean; + /** + * Ps=14 Report xterm text area size in pixels. Result is "CSI 4 ; height ; width t". + * Ps=14 ; 2 Report xterm window size in pixels. Result is "CSI 4 ; height ; width t". + * Has a default implementation. + */ + getWinSizePixels?: boolean; + /** + * Ps=15 Report size of the screen in pixels. Result is "CSI 5 ; height ; width t". + * No default implementation. + */ + getScreenSizePixels?: boolean; + /** + * Ps=16 Report xterm character cell size in pixels. Result is "CSI 6 ; height ; width t". + * Has a default implementation. + */ + getCellSizePixels?: boolean; + /** + * Ps=18 Report the size of the text area in characters. Result is "CSI 8 ; height ; width t". + * Has a default implementation. + */ + getWinSizeChars?: boolean; + /** + * Ps=19 Report the size of the screen in characters. Result is "CSI 9 ; height ; width t". + * No default implementation. + */ + getScreenSizeChars?: boolean; + /** + * Ps=20 Report xterm window's icon label. Result is "OSC L label ST". + * No default implementation. + */ + getIconTitle?: boolean; + /** + * Ps=21 Report xterm window's title. Result is "OSC l label ST". + * No default implementation. + */ + getWinTitle?: boolean; + /** + * Ps=22 ; 0 Save xterm icon and window title on stack. + * Ps=22 ; 1 Save xterm icon title on stack. + * Ps=22 ; 2 Save xterm window title on stack. + * All variants have a default implementation. + */ + pushTitle?: boolean; + /** + * Ps=23 ; 0 Restore xterm icon and window title from stack. + * Ps=23 ; 1 Restore xterm icon title from stack. + * Ps=23 ; 2 Restore xterm window title from stack. + * All variants have a default implementation. + */ + popTitle?: boolean; + /** + * Ps>=24 Resize to Ps lines (DECSLPP). + * DECSLPP is not implemented. This settings is also used to + * enable / disable DECCOLM (earlier variant of DECSLPP). + */ + setWinLines?: boolean; + } + + /** + * The class that represents an xterm.js terminal. + */ + export class Terminal implements IDisposable { + /** + * The number of rows in the terminal's viewport. Use + * `ITerminalOptions.rows` to set this in the constructor and + * `Terminal.resize` for when the terminal exists. + */ + readonly rows: number; + + /** + * The number of columns in the terminal's viewport. Use + * `ITerminalOptions.cols` to set this in the constructor and + * `Terminal.resize` for when the terminal exists. + */ + readonly cols: number; + + /** + * (EXPERIMENTAL) The terminal's current buffer, this might be either the + * normal buffer or the alt buffer depending on what's running in the + * terminal. + */ + readonly buffer: IBufferNamespace; + + /** + * (EXPERIMENTAL) Get all markers registered against the buffer. If the alt + * buffer is active this will always return []. + */ + readonly markers: ReadonlyArray; + + /** + * (EXPERIMENTAL) Get the parser interface to register + * custom escape sequence handlers. + */ + readonly parser: IParser; + + /** + * (EXPERIMENTAL) Get the Unicode handling interface + * to register and switch Unicode version. + */ + readonly unicode: IUnicodeHandling; + + /** + * Gets the terminal modes as set by SM/DECSET. + */ + readonly modes: IModes; + + /** + * Natural language strings that can be localized. + */ + static strings: ILocalizableStrings; + + /** + * Creates a new `Terminal` object. + * + * @param options An object containing a set of options. + */ + constructor(options?: ITerminalOptions); + + /** + * Adds an event listener for when the bell is triggered. * @returns an `IDisposable` to stop listening. */ - export interface IEvent { - (listener: (arg1: T, arg2: U) => any): IDisposable; - } + onBell: IEvent; /** - * Represents a specific line in the terminal that is tracked when scrollback - * is trimmed and lines are added or removed. This is a single line that may - * be part of a larger wrapped line. + * Adds an event listener for when a binary event fires. This is used to + * enable non UTF-8 conformant binary messages to be sent to the backend. + * Currently this is only used for a certain type of mouse reports that + * happen to be not UTF-8 compatible. + * The event value is a JS string, pass it to the underlying pty as + * binary data, e.g. `pty.write(Buffer.from(data, 'binary'))`. + * @returns an `IDisposable` to stop listening. */ - export interface IMarker extends IDisposable { - /** - * A unique identifier for this marker. - */ - readonly id: number; - - /** - * Whether this marker is disposed. - */ - readonly isDisposed: boolean; - - /** - * The actual line index in the buffer at this point in time. This is set to - * -1 if the marker has been disposed. - */ - readonly line: number; - - /** - * Event listener to get notified when the marker gets disposed. Automatic disposal - * might happen for a marker, that got invalidated by scrolling out or removal of - * a line from the buffer. - */ - onDispose: IEvent; - } + onBinary: IEvent; /** - * The set of localizable strings. + * Adds an event listener for the cursor moves. + * @returns an `IDisposable` to stop listening. */ - export interface ILocalizableStrings { - /** - * The aria label for the underlying input textarea for the terminal. - */ - promptLabel: string; - - /** - * Announcement for when line reading is suppressed due to too many lines - * being printed to the terminal when `screenReaderMode` is enabled. - */ - tooMuchOutput: string; - } + onCursorMove: IEvent; /** - * Enable various window manipulation and report features (CSI Ps ; Ps ; Ps t). - * - * Most settings have no default implementation, as they heavily rely on - * the embedding environment. - * - * To implement a feature, create a custom CSI hook like this: - * ```ts - * term.parser.addCsiHandler({final: 't'}, params => { - * const ps = params[0]; - * switch (ps) { - * case XY: - * ... // your implementation for option XY - * return true; // signal Ps=XY was handled - * } - * return false; // any Ps that was not handled - * }); - * ``` - * - * Note on security: - * Most features are meant to deal with some information of the host machine - * where the terminal runs on. This is seen as a security risk possibly leaking - * sensitive data of the host to the program in the terminal. Therefore all options - * (even those without a default implementation) are guarded by the boolean flag - * and disabled by default. + * Adds an event listener for when a data event fires. This happens for + * example when the user types or pastes into the terminal. The event value + * is whatever `string` results, in a typical setup, this should be passed + * on to the backing pty. + * @returns an `IDisposable` to stop listening. */ - export interface IWindowOptions { - /** - * Ps=1 De-iconify window. - * No default implementation. - */ - restoreWin?: boolean; - /** - * Ps=2 Iconify window. - * No default implementation. - */ - minimizeWin?: boolean; - /** - * Ps=3 ; x ; y - * Move window to [x, y]. - * No default implementation. - */ - setWinPosition?: boolean; - /** - * Ps = 4 ; height ; width - * Resize the window to given `height` and `width` in pixels. - * Omitted parameters should reuse the current height or width. - * Zero parameters should use the display's height or width. - * No default implementation. - */ - setWinSizePixels?: boolean; - /** - * Ps=5 Raise the window to the front of the stacking order. - * No default implementation. - */ - raiseWin?: boolean; - /** - * Ps=6 Lower the xterm window to the bottom of the stacking order. - * No default implementation. - */ - lowerWin?: boolean; - /** Ps=7 Refresh the window. */ - refreshWin?: boolean; - /** - * Ps = 8 ; height ; width - * Resize the text area to given height and width in characters. - * Omitted parameters should reuse the current height or width. - * Zero parameters use the display's height or width. - * No default implementation. - */ - setWinSizeChars?: boolean; - /** - * Ps=9 ; 0 Restore maximized window. - * Ps=9 ; 1 Maximize window (i.e., resize to screen size). - * Ps=9 ; 2 Maximize window vertically. - * Ps=9 ; 3 Maximize window horizontally. - * No default implementation. - */ - maximizeWin?: boolean; - /** - * Ps=10 ; 0 Undo full-screen mode. - * Ps=10 ; 1 Change to full-screen. - * Ps=10 ; 2 Toggle full-screen. - * No default implementation. - */ - fullscreenWin?: boolean; - /** Ps=11 Report xterm window state. - * If the xterm window is non-iconified, it returns "CSI 1 t". - * If the xterm window is iconified, it returns "CSI 2 t". - * No default implementation. - */ - getWinState?: boolean; - /** - * Ps=13 Report xterm window position. Result is "CSI 3 ; x ; y t". - * Ps=13 ; 2 Report xterm text-area position. Result is "CSI 3 ; x ; y t". - * No default implementation. - */ - getWinPosition?: boolean; - /** - * Ps=14 Report xterm text area size in pixels. Result is "CSI 4 ; height ; width t". - * Ps=14 ; 2 Report xterm window size in pixels. Result is "CSI 4 ; height ; width t". - * Has a default implementation. - */ - getWinSizePixels?: boolean; - /** - * Ps=15 Report size of the screen in pixels. Result is "CSI 5 ; height ; width t". - * No default implementation. - */ - getScreenSizePixels?: boolean; - /** - * Ps=16 Report xterm character cell size in pixels. Result is "CSI 6 ; height ; width t". - * Has a default implementation. - */ - getCellSizePixels?: boolean; - /** - * Ps=18 Report the size of the text area in characters. Result is "CSI 8 ; height ; width t". - * Has a default implementation. - */ - getWinSizeChars?: boolean; - /** - * Ps=19 Report the size of the screen in characters. Result is "CSI 9 ; height ; width t". - * No default implementation. - */ - getScreenSizeChars?: boolean; - /** - * Ps=20 Report xterm window's icon label. Result is "OSC L label ST". - * No default implementation. - */ - getIconTitle?: boolean; - /** - * Ps=21 Report xterm window's title. Result is "OSC l label ST". - * No default implementation. - */ - getWinTitle?: boolean; - /** - * Ps=22 ; 0 Save xterm icon and window title on stack. - * Ps=22 ; 1 Save xterm icon title on stack. - * Ps=22 ; 2 Save xterm window title on stack. - * All variants have a default implementation. - */ - pushTitle?: boolean; - /** - * Ps=23 ; 0 Restore xterm icon and window title from stack. - * Ps=23 ; 1 Restore xterm icon title from stack. - * Ps=23 ; 2 Restore xterm window title from stack. - * All variants have a default implementation. - */ - popTitle?: boolean; - /** - * Ps>=24 Resize to Ps lines (DECSLPP). - * DECSLPP is not implemented. This settings is also used to - * enable / disable DECCOLM (earlier variant of DECSLPP). - */ - setWinLines?: boolean; - } + onData: IEvent; /** - * The class that represents an xterm.js terminal. + * Adds an event listener for when a line feed is added. + * @returns an `IDisposable` to stop listening. */ - export class Terminal implements IDisposable { - /** - * The number of rows in the terminal's viewport. Use - * `ITerminalOptions.rows` to set this in the constructor and - * `Terminal.resize` for when the terminal exists. - */ - readonly rows: number; + onLineFeed: IEvent; - /** - * The number of columns in the terminal's viewport. Use - * `ITerminalOptions.cols` to set this in the constructor and - * `Terminal.resize` for when the terminal exists. - */ - readonly cols: number; + /** + * Adds an event listener for when the terminal is resized. The event value + * contains the new size. + * @returns an `IDisposable` to stop listening. + */ + onResize: IEvent<{ cols: number, rows: number }>; - /** - * (EXPERIMENTAL) The terminal's current buffer, this might be either the - * normal buffer or the alt buffer depending on what's running in the - * terminal. - */ - readonly buffer: IBufferNamespace; + /** + * Adds an event listener for when a scroll occurs. The event value is the + * new position of the viewport. + * @returns an `IDisposable` to stop listening. + */ + onScroll: IEvent; - /** - * (EXPERIMENTAL) Get all markers registered against the buffer. If the alt - * buffer is active this will always return []. - */ - readonly markers: ReadonlyArray; + /** + * Adds an event listener for when an OSC 0 or OSC 2 title change occurs. + * The event value is the new title. + * @returns an `IDisposable` to stop listening. + */ + onTitleChange: IEvent; - /** - * (EXPERIMENTAL) Get the parser interface to register - * custom escape sequence handlers. - */ - readonly parser: IParser; + /** + * Resizes the terminal. It's best practice to debounce calls to resize, + * this will help ensure that the pty can respond to the resize event + * before another one occurs. + * @param x The number of columns to resize to. + * @param y The number of rows to resize to. + */ + resize(columns: number, rows: number): void; - /** - * (EXPERIMENTAL) Get the Unicode handling interface - * to register and switch Unicode version. - */ - readonly unicode: IUnicodeHandling; + /** + * (EXPERIMENTAL) Adds a marker to the normal buffer and returns it. If the + * alt buffer is active, undefined is returned. + * @param cursorYOffset The y position offset of the marker from the cursor. + * @returns The new marker or undefined. + */ + registerMarker(cursorYOffset: number): IMarker | undefined; - /** - * Natural language strings that can be localized. - */ - static strings: ILocalizableStrings; + /** + * @deprecated use `registerMarker` instead. + */ + addMarker(cursorYOffset: number): IMarker | undefined; - /** - * Creates a new `Terminal` object. - * - * @param options An object containing a set of options. - */ - constructor(options?: ITerminalOptions); - - /** - * Adds an event listener for when the bell is triggered. - * @returns an `IDisposable` to stop listening. - */ - onBell: IEvent; - - /** - * Adds an event listener for when a binary event fires. This is used to - * enable non UTF-8 conformant binary messages to be sent to the backend. - * Currently this is only used for a certain type of mouse reports that - * happen to be not UTF-8 compatible. - * The event value is a JS string, pass it to the underlying pty as - * binary data, e.g. `pty.write(Buffer.from(data, 'binary'))`. - * @returns an `IDisposable` to stop listening. - */ - onBinary: IEvent; - - /** - * Adds an event listener for the cursor moves. - * @returns an `IDisposable` to stop listening. - */ - onCursorMove: IEvent; - - /** - * Adds an event listener for when a data event fires. This happens for - * example when the user types or pastes into the terminal. The event value - * is whatever `string` results, in a typical setup, this should be passed - * on to the backing pty. - * @returns an `IDisposable` to stop listening. - */ - onData: IEvent; - - /** - * Adds an event listener for when a line feed is added. - * @returns an `IDisposable` to stop listening. - */ - onLineFeed: IEvent; - - /** - * Adds an event listener for when the terminal is resized. The event value - * contains the new size. - * @returns an `IDisposable` to stop listening. - */ - onResize: IEvent<{ cols: number, rows: number }>; - - /** - * Adds an event listener for when a scroll occurs. The event value is the - * new position of the viewport. - * @returns an `IDisposable` to stop listening. - */ - onScroll: IEvent; - - /** - * Adds an event listener for when an OSC 0 or OSC 2 title change occurs. - * The event value is the new title. - * @returns an `IDisposable` to stop listening. - */ - onTitleChange: IEvent; - - /** - * Resizes the terminal. It's best practice to debounce calls to resize, - * this will help ensure that the pty can respond to the resize event - * before another one occurs. - * @param x The number of columns to resize to. - * @param y The number of rows to resize to. - */ - resize(columns: number, rows: number): void; - - /** - * (EXPERIMENTAL) Adds a marker to the normal buffer and returns it. If the - * alt buffer is active, undefined is returned. - * @param cursorYOffset The y position offset of the marker from the cursor. - * @returns The new marker or undefined. - */ - registerMarker(cursorYOffset: number): IMarker | undefined; - - /** - * @deprecated use `registerMarker` instead. - */ - addMarker(cursorYOffset: number): IMarker | undefined; - - /* - * Disposes of the terminal, detaching it from the DOM and removing any - * active listeners. - */ - dispose(): void; - - /** - * Scroll the display of the terminal - * @param amount The number of lines to scroll down (negative scroll up). - */ - scrollLines(amount: number): void; - - /** - * Scroll the display of the terminal by a number of pages. - * @param pageCount The number of pages to scroll (negative scrolls up). - */ - scrollPages(pageCount: number): void; - - /** - * Scrolls the display of the terminal to the top. - */ - scrollToTop(): void; - - /** - * Scrolls the display of the terminal to the bottom. - */ - scrollToBottom(): void; - - /** - * Scrolls to a line within the buffer. - * @param line The 0-based line index to scroll to. - */ - scrollToLine(line: number): void; - - /** - * Clear the entire buffer, making the prompt line the new first line. - */ - clear(): void; - - /** - * Write data to the terminal. - * @param data The data to write to the terminal. This can either be raw - * bytes given as Uint8Array from the pty or a string. Raw bytes will always - * be treated as UTF-8 encoded, string data as UTF-16. - * @param callback Optional callback that fires when the data was processed - * by the parser. - */ - write(data: string | Uint8Array, callback?: () => void): void; - - /** - * Writes data to the terminal, followed by a break line character (\n). - * @param data The data to write to the terminal. This can either be raw - * bytes given as Uint8Array from the pty or a string. Raw bytes will always - * be treated as UTF-8 encoded, string data as UTF-16. - * @param callback Optional callback that fires when the data was processed - * by the parser. - */ - writeln(data: string | Uint8Array, callback?: () => void): void; - - /** - * Write UTF8 data to the terminal. - * @param data The data to write to the terminal. - * @param callback Optional callback when data was processed. - * @deprecated use `write` instead - */ - writeUtf8(data: Uint8Array, callback?: () => void): void; - - /** - * Retrieves an option's value from the terminal. - * @param key The option key. - */ - getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string; - /** - * Retrieves an option's value from the terminal. - * @param key The option key. - */ - getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell' | 'windowsMode'): boolean; - /** - * Retrieves an option's value from the terminal. - * @param key The option key. - */ - getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number; - /** - * Retrieves an option's value from the terminal. - * @param key The option key. - */ - getOption(key: string): any; - - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'fontFamily' | 'termName' | 'bellSound' | 'wordSeparator', value: string): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. + /* + * Disposes of the terminal, detaching it from the DOM and removing any + * active listeners. */ - setOption(key: 'fontWeight' | 'fontWeightBold', value: null | 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'logLevel', value: LogLevel): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'bellStyle', value: null | 'none' | 'visual' | 'sound' | 'both'): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'cursorStyle', value: null | 'block' | 'underline' | 'bar'): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'popOnBell' | 'rightClickSelectsWord' | 'visualBell' | 'windowsMode', value: boolean): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'theme', value: ITheme): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'cols' | 'rows', value: number): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: string, value: any): void; - - /** - * Perform a full reset (RIS, aka '\x1bc'). - */ - reset(): void; - - /** - * Loads an addon into this instance of xterm.js. - * @param addon The addon to load. - */ - loadAddon(addon: ITerminalAddon): void; - } + dispose(): void; /** - * An addon that can provide additional functionality to the terminal. + * Scroll the display of the terminal + * @param amount The number of lines to scroll down (negative scroll up). */ - export interface ITerminalAddon extends IDisposable { - /** - * This is called when the addon is activated. - */ - activate(terminal: Terminal): void; - } + scrollLines(amount: number): void; /** - * An object representing a selection within the terminal. + * Scroll the display of the terminal by a number of pages. + * @param pageCount The number of pages to scroll (negative scrolls up). */ - interface ISelectionPosition { - /** - * The start column of the selection. - */ - startColumn: number; - - /** - * The start row of the selection. - */ - startRow: number; - - /** - * The end column of the selection. - */ - endColumn: number; - - /** - * The end row of the selection. - */ - endRow: number; - } + scrollPages(pageCount: number): void; /** - * An object representing a range within the viewport of the terminal. + * Scrolls the display of the terminal to the top. */ - export interface IViewportRange { - /** - * The start of the range. - */ - start: IViewportRangePosition; - - /** - * The end of the range. - */ - end: IViewportRangePosition; - } + scrollToTop(): void; /** - * An object representing a cell position within the viewport of the terminal. + * Scrolls the display of the terminal to the bottom. */ - interface IViewportRangePosition { - /** - * The x position of the cell. This is a 0-based index that refers to the - * space in between columns, not the column itself. Index 0 refers to the - * left side of the viewport, index `Terminal.cols` refers to the right side - * of the viewport. This can be thought of as how a cursor is positioned in - * a text editor. - */ - x: number; - - /** - * The y position of the cell. This is a 0-based index that refers to a - * specific row. - */ - y: number; - } + scrollToBottom(): void; /** - * A range within a buffer. + * Scrolls to a line within the buffer. + * @param line The 0-based line index to scroll to. */ - interface IBufferRange { - /** - * The start position of the range. - */ - start: IBufferCellPosition; - - /** - * The end position of the range. - */ - end: IBufferCellPosition; - } + scrollToLine(line: number): void; /** - * A position within a buffer. + * Clear the entire buffer, making the prompt line the new first line. */ - interface IBufferCellPosition { - /** - * The x position within the buffer. - */ - x: number; - - /** - * The y position within the buffer. - */ - y: number; - } + clear(): void; /** - * Represents a terminal buffer. + * Write data to the terminal. + * @param data The data to write to the terminal. This can either be raw + * bytes given as Uint8Array from the pty or a string. Raw bytes will always + * be treated as UTF-8 encoded, string data as UTF-16. + * @param callback Optional callback that fires when the data was processed + * by the parser. */ - interface IBuffer { - /** - * The type of the buffer. - */ - readonly type: 'normal' | 'alternate'; - - /** - * The y position of the cursor. This ranges between `0` (when the - * cursor is at baseY) and `Terminal.rows - 1` (when the cursor is on the - * last row). - */ - readonly cursorY: number; - - /** - * The x position of the cursor. This ranges between `0` (left side) and - * `Terminal.cols` (after last cell of the row). - */ - readonly cursorX: number; - - /** - * The line within the buffer where the top of the viewport is. - */ - readonly viewportY: number; - - /** - * The line within the buffer where the top of the bottom page is (when - * fully scrolled down). - */ - readonly baseY: number; - - /** - * The amount of lines in the buffer. - */ - readonly length: number; - - /** - * Gets a line from the buffer, or undefined if the line index does not - * exist. - * - * Note that the result of this function should be used immediately after - * calling as when the terminal updates it could lead to unexpected - * behavior. - * - * @param y The line index to get. - */ - getLine(y: number): IBufferLine | undefined; - - /** - * Creates an empty cell object suitable as a cell reference in - * `line.getCell(x, cell)`. Use this to avoid costly recreation of - * cell objects when dealing with tons of cells. - */ - getNullCell(): IBufferCell; - } + write(data: string | Uint8Array, callback?: () => void): void; /** - * Represents the terminal's set of buffers. + * Writes data to the terminal, followed by a break line character (\n). + * @param data The data to write to the terminal. This can either be raw + * bytes given as Uint8Array from the pty or a string. Raw bytes will always + * be treated as UTF-8 encoded, string data as UTF-16. + * @param callback Optional callback that fires when the data was processed + * by the parser. */ - interface IBufferNamespace { - /** - * The active buffer, this will either be the normal or alternate buffers. - */ - readonly active: IBuffer; - - /** - * The normal buffer. - */ - readonly normal: IBuffer; - - /** - * The alternate buffer, this becomes the active buffer when an application - * enters this mode via DECSET (`CSI ? 4 7 h`) - */ - readonly alternate: IBuffer; - - /** - * Adds an event listener for when the active buffer changes. - * @returns an `IDisposable` to stop listening. - */ - onBufferChange: IEvent; - } + writeln(data: string | Uint8Array, callback?: () => void): void; /** - * Represents a line in the terminal's buffer. + * Write UTF8 data to the terminal. + * @param data The data to write to the terminal. + * @param callback Optional callback when data was processed. + * @deprecated use `write` instead */ - interface IBufferLine { - /** - * Whether the line is wrapped from the previous line. - */ - readonly isWrapped: boolean; - - /** - * The length of the line, all call to getCell beyond the length will result - * in `undefined`. - */ - readonly length: number; - - /** - * Gets a cell from the line, or undefined if the line index does not exist. - * - * Note that the result of this function should be used immediately after - * calling as when the terminal updates it could lead to unexpected - * behavior. - * - * @param x The character index to get. - * @param cell Optional cell object to load data into for performance - * reasons. This is mainly useful when every cell in the buffer is being - * looped over to avoid creating new objects for every cell. - */ - getCell(x: number, cell?: IBufferCell): IBufferCell | undefined; - - /** - * Gets the line as a string. Note that this is gets only the string for the - * line, not taking isWrapped into account. - * - * @param trimRight Whether to trim any whitespace at the right of the line. - * @param startColumn The column to start from (inclusive). - * @param endColumn The column to end at (exclusive). - */ - translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string; - } + writeUtf8(data: Uint8Array, callback?: () => void): void; /** - * Represents a single cell in the terminal's buffer. + * Retrieves an option's value from the terminal. + * @param key The option key. */ - interface IBufferCell { - /** - * The width of the character. Some examples: - * - * - `1` for most cells. - * - `2` for wide character like CJK glyphs. - * - `0` for cells immediately following cells with a width of `2`. - */ - getWidth(): number; - - /** - * The character(s) within the cell. Examples of what this can contain: - * - * - A normal width character - * - A wide character (eg. CJK) - * - An emoji - */ - getChars(): string; - - /** - * Gets the UTF32 codepoint of single characters, if content is a combined - * string it returns the codepoint of the last character in the string. - */ - getCode(): number; - - /** - * Gets the number representation of the foreground color mode, this can be - * used to perform quick comparisons of 2 cells to see if they're the same. - * Use `isFgRGB`, `isFgPalette` and `isFgDefault` to check what color mode - * a cell is. - */ - getFgColorMode(): number; - - /** - * Gets the number representation of the background color mode, this can be - * used to perform quick comparisons of 2 cells to see if they're the same. - * Use `isBgRGB`, `isBgPalette` and `isBgDefault` to check what color mode - * a cell is. - */ - getBgColorMode(): number; - - /** - * Gets a cell's foreground color number, this differs depending on what the - * color mode of the cell is: - * - * - Default: This should be 0, representing the default foreground color - * (CSI 39 m). - * - Palette: This is a number from 0 to 255 of ANSI colors (CSI 3(0-7) m, - * CSI 9(0-7) m, CSI 38 ; 5 ; 0-255 m). - * - RGB: A hex value representing a 'true color': 0xRRGGBB. - * (CSI 3 8 ; 2 ; Pi ; Pr ; Pg ; Pb) - */ - getFgColor(): number; - - /** - * Gets a cell's background color number, this differs depending on what the - * color mode of the cell is: - * - * - Default: This should be 0, representing the default background color - * (CSI 49 m). - * - Palette: This is a number from 0 to 255 of ANSI colors - * (CSI 4(0-7) m, CSI 10(0-7) m, CSI 48 ; 5 ; 0-255 m). - * - RGB: A hex value representing a 'true color': 0xRRGGBB - * (CSI 4 8 ; 2 ; Pi ; Pr ; Pg ; Pb) - */ - getBgColor(): number; - - /** Whether the cell has the bold attribute (CSI 1 m). */ - isBold(): number; - /** Whether the cell has the inverse attribute (CSI 3 m). */ - isItalic(): number; - /** Whether the cell has the inverse attribute (CSI 2 m). */ - isDim(): number; - /** Whether the cell has the underline attribute (CSI 4 m). */ - isUnderline(): number; - /** Whether the cell has the inverse attribute (CSI 5 m). */ - isBlink(): number; - /** Whether the cell has the inverse attribute (CSI 7 m). */ - isInverse(): number; - /** Whether the cell has the inverse attribute (CSI 8 m). */ - isInvisible(): number; - - /** Whether the cell is using the RGB foreground color mode. */ - isFgRGB(): boolean; - /** Whether the cell is using the RGB background color mode. */ - isBgRGB(): boolean; - /** Whether the cell is using the palette foreground color mode. */ - isFgPalette(): boolean; - /** Whether the cell is using the palette background color mode. */ - isBgPalette(): boolean; - /** Whether the cell is using the default foreground color mode. */ - isFgDefault(): boolean; - /** Whether the cell is using the default background color mode. */ - isBgDefault(): boolean; - - /** Whether the cell has the default attribute (no color or style). */ - isAttributeDefault(): boolean; - } + getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string; + /** + * Retrieves an option's value from the terminal. + * @param key The option key. + */ + getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell' | 'windowsMode'): boolean; + /** + * Retrieves an option's value from the terminal. + * @param key The option key. + */ + getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number; + /** + * Retrieves an option's value from the terminal. + * @param key The option key. + */ + getOption(key: string): any; /** - * Data type to register a CSI, DCS or ESC callback in the parser - * in the form: - * ESC I..I F - * CSI Prefix P..P I..I F - * DCS Prefix P..P I..I F data_bytes ST - * - * with these rules/restrictions: - * - prefix can only be used with CSI and DCS - * - only one leading prefix byte is recognized by the parser - * before any other parameter bytes (P..P) - * - intermediate bytes are recognized up to 2 - * - * For custom sequences make sure to read ECMA-48 and the resources at - * vt100.net to not clash with existing sequences or reserved address space. - * General recommendations: - * - use private address space (see ECMA-48) - * - use max one intermediate byte (technically not limited by the spec, - * in practice there are no sequences with more than one intermediate byte, - * thus parsers might get confused with more intermediates) - * - test against other common emulators to check whether they escape/ignore - * the sequence correctly - * - * Notes: OSC command registration is handled differently (see addOscHandler) - * APC, PM or SOS is currently not supported. + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. */ - export interface IFunctionIdentifier { - /** - * Optional prefix byte, must be in range \x3c .. \x3f. - * Usable in CSI and DCS. - */ - prefix?: string; - /** - * Optional intermediate bytes, must be in range \x20 .. \x2f. - * Usable in CSI, DCS and ESC. - */ - intermediates?: string; - /** - * Final byte, must be in range \x40 .. \x7e for CSI and DCS, - * \x30 .. \x7e for ESC. - */ - final: string; - } + setOption(key: 'fontFamily' | 'termName' | 'bellSound' | 'wordSeparator', value: string): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'fontWeight' | 'fontWeightBold', value: null | 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'logLevel', value: LogLevel): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'bellStyle', value: null | 'none' | 'visual' | 'sound' | 'both'): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'cursorStyle', value: null | 'block' | 'underline' | 'bar'): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'popOnBell' | 'rightClickSelectsWord' | 'visualBell' | 'windowsMode', value: boolean): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'theme', value: ITheme): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: 'cols' | 'rows', value: number): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: string, value: any): void; /** - * Allows hooking into the parser for custom handling of escape sequences. + * Perform a full reset (RIS, aka '\x1bc'). */ - export interface IParser { - /** - * Adds a handler for CSI escape sequences. - * @param id Specifies the function identifier under which the callback - * gets registered, e.g. {final: 'm'} for SGR. - * @param callback The function to handle the sequence. The callback is - * called with the numerical params. If the sequence has subparams the - * array will contain subarrays with their numercial values. - * Return true if the sequence was handled; false if we should try - * a previous handler (set by addCsiHandler or setCsiHandler). - * The most recently added handler is tried first. - * @return An IDisposable you can call to remove this handler. - */ - registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable; - - /** - * Adds a handler for DCS escape sequences. - * @param id Specifies the function identifier under which the callback - * gets registered, e.g. {intermediates: '$' final: 'q'} for DECRQSS. - * @param callback The function to handle the sequence. Note that the - * function will only be called once if the sequence finished sucessfully. - * There is currently no way to intercept smaller data chunks, data chunks - * will be stored up until the sequence is finished. Since DCS sequences - * are not limited by the amount of data this might impose a problem for - * big payloads. Currently xterm.js limits DCS payload to 10 MB - * which should give enough room for most use cases. - * The function gets the payload and numerical parameters as arguments. - * Return true if the sequence was handled; false if we should try - * a previous handler (set by addDcsHandler or setDcsHandler). - * The most recently added handler is tried first. - * @return An IDisposable you can call to remove this handler. - */ - registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable; - - /** - * Adds a handler for ESC escape sequences. - * @param id Specifies the function identifier under which the callback - * gets registered, e.g. {intermediates: '%' final: 'G'} for - * default charset selection. - * @param callback The function to handle the sequence. - * Return true if the sequence was handled; false if we should try - * a previous handler (set by addEscHandler or setEscHandler). - * The most recently added handler is tried first. - * @return An IDisposable you can call to remove this handler. - */ - registerEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable; - - /** - * Adds a handler for OSC escape sequences. - * @param ident The number (first parameter) of the sequence. - * @param callback The function to handle the sequence. Note that the - * function will only be called once if the sequence finished sucessfully. - * There is currently no way to intercept smaller data chunks, data chunks - * will be stored up until the sequence is finished. Since OSC sequences - * are not limited by the amount of data this might impose a problem for - * big payloads. Currently xterm.js limits OSC payload to 10 MB - * which should give enough room for most use cases. - * The callback is called with OSC data string. - * Return true if the sequence was handled; false if we should try - * a previous handler (set by addOscHandler or setOscHandler). - * The most recently added handler is tried first. - * @return An IDisposable you can call to remove this handler. - */ - registerOscHandler(ident: number, callback: (data: string) => boolean): IDisposable; - } + reset(): void; /** - * (EXPERIMENTAL) Unicode version provider. - * Used to register custom Unicode versions with `Terminal.unicode.register`. + * Loads an addon into this instance of xterm.js. + * @param addon The addon to load. */ - export interface IUnicodeVersionProvider { - /** - * String indicating the Unicode version provided. - */ - readonly version: string; - - /** - * Unicode version dependent wcwidth implementation. - */ - wcwidth(codepoint: number): 0 | 1 | 2; - } - - /** - * (EXPERIMENTAL) Unicode handling interface. - */ - export interface IUnicodeHandling { - /** - * Register a custom Unicode version provider. - */ - register(provider: IUnicodeVersionProvider): void; - - /** - * Registered Unicode versions. - */ - readonly versions: ReadonlyArray; - - /** - * Getter/setter for active Unicode version. - */ - activeVersion: string; - } + loadAddon(addon: ITerminalAddon): void; } + + /** + * An addon that can provide additional functionality to the terminal. + */ + export interface ITerminalAddon extends IDisposable { + /** + * This is called when the addon is activated. + */ + activate(terminal: Terminal): void; + } + + /** + * An object representing a selection within the terminal. + */ + interface ISelectionPosition { + /** + * The start column of the selection. + */ + startColumn: number; + + /** + * The start row of the selection. + */ + startRow: number; + + /** + * The end column of the selection. + */ + endColumn: number; + + /** + * The end row of the selection. + */ + endRow: number; + } + + /** + * An object representing a range within the viewport of the terminal. + */ + export interface IViewportRange { + /** + * The start of the range. + */ + start: IViewportRangePosition; + + /** + * The end of the range. + */ + end: IViewportRangePosition; + } + + /** + * An object representing a cell position within the viewport of the terminal. + */ + interface IViewportRangePosition { + /** + * The x position of the cell. This is a 0-based index that refers to the + * space in between columns, not the column itself. Index 0 refers to the + * left side of the viewport, index `Terminal.cols` refers to the right side + * of the viewport. This can be thought of as how a cursor is positioned in + * a text editor. + */ + x: number; + + /** + * The y position of the cell. This is a 0-based index that refers to a + * specific row. + */ + y: number; + } + + /** + * A range within a buffer. + */ + interface IBufferRange { + /** + * The start position of the range. + */ + start: IBufferCellPosition; + + /** + * The end position of the range. + */ + end: IBufferCellPosition; + } + + /** + * A position within a buffer. + */ + interface IBufferCellPosition { + /** + * The x position within the buffer. + */ + x: number; + + /** + * The y position within the buffer. + */ + y: number; + } + + /** + * Represents a terminal buffer. + */ + interface IBuffer { + /** + * The type of the buffer. + */ + readonly type: 'normal' | 'alternate'; + + /** + * The y position of the cursor. This ranges between `0` (when the + * cursor is at baseY) and `Terminal.rows - 1` (when the cursor is on the + * last row). + */ + readonly cursorY: number; + + /** + * The x position of the cursor. This ranges between `0` (left side) and + * `Terminal.cols` (after last cell of the row). + */ + readonly cursorX: number; + + /** + * The line within the buffer where the top of the viewport is. + */ + readonly viewportY: number; + + /** + * The line within the buffer where the top of the bottom page is (when + * fully scrolled down). + */ + readonly baseY: number; + + /** + * The amount of lines in the buffer. + */ + readonly length: number; + + /** + * Gets a line from the buffer, or undefined if the line index does not + * exist. + * + * Note that the result of this function should be used immediately after + * calling as when the terminal updates it could lead to unexpected + * behavior. + * + * @param y The line index to get. + */ + getLine(y: number): IBufferLine | undefined; + + /** + * Creates an empty cell object suitable as a cell reference in + * `line.getCell(x, cell)`. Use this to avoid costly recreation of + * cell objects when dealing with tons of cells. + */ + getNullCell(): IBufferCell; + } + + /** + * Represents the terminal's set of buffers. + */ + interface IBufferNamespace { + /** + * The active buffer, this will either be the normal or alternate buffers. + */ + readonly active: IBuffer; + + /** + * The normal buffer. + */ + readonly normal: IBuffer; + + /** + * The alternate buffer, this becomes the active buffer when an application + * enters this mode via DECSET (`CSI ? 4 7 h`) + */ + readonly alternate: IBuffer; + + /** + * Adds an event listener for when the active buffer changes. + * @returns an `IDisposable` to stop listening. + */ + onBufferChange: IEvent; + } + + /** + * Represents a line in the terminal's buffer. + */ + interface IBufferLine { + /** + * Whether the line is wrapped from the previous line. + */ + readonly isWrapped: boolean; + + /** + * The length of the line, all call to getCell beyond the length will result + * in `undefined`. + */ + readonly length: number; + + /** + * Gets a cell from the line, or undefined if the line index does not exist. + * + * Note that the result of this function should be used immediately after + * calling as when the terminal updates it could lead to unexpected + * behavior. + * + * @param x The character index to get. + * @param cell Optional cell object to load data into for performance + * reasons. This is mainly useful when every cell in the buffer is being + * looped over to avoid creating new objects for every cell. + */ + getCell(x: number, cell?: IBufferCell): IBufferCell | undefined; + + /** + * Gets the line as a string. Note that this is gets only the string for the + * line, not taking isWrapped into account. + * + * @param trimRight Whether to trim any whitespace at the right of the line. + * @param startColumn The column to start from (inclusive). + * @param endColumn The column to end at (exclusive). + */ + translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string; + } + + /** + * Represents a single cell in the terminal's buffer. + */ + interface IBufferCell { + /** + * The width of the character. Some examples: + * + * - `1` for most cells. + * - `2` for wide character like CJK glyphs. + * - `0` for cells immediately following cells with a width of `2`. + */ + getWidth(): number; + + /** + * The character(s) within the cell. Examples of what this can contain: + * + * - A normal width character + * - A wide character (eg. CJK) + * - An emoji + */ + getChars(): string; + + /** + * Gets the UTF32 codepoint of single characters, if content is a combined + * string it returns the codepoint of the last character in the string. + */ + getCode(): number; + + /** + * Gets the number representation of the foreground color mode, this can be + * used to perform quick comparisons of 2 cells to see if they're the same. + * Use `isFgRGB`, `isFgPalette` and `isFgDefault` to check what color mode + * a cell is. + */ + getFgColorMode(): number; + + /** + * Gets the number representation of the background color mode, this can be + * used to perform quick comparisons of 2 cells to see if they're the same. + * Use `isBgRGB`, `isBgPalette` and `isBgDefault` to check what color mode + * a cell is. + */ + getBgColorMode(): number; + + /** + * Gets a cell's foreground color number, this differs depending on what the + * color mode of the cell is: + * + * - Default: This should be 0, representing the default foreground color + * (CSI 39 m). + * - Palette: This is a number from 0 to 255 of ANSI colors (CSI 3(0-7) m, + * CSI 9(0-7) m, CSI 38 ; 5 ; 0-255 m). + * - RGB: A hex value representing a 'true color': 0xRRGGBB. + * (CSI 3 8 ; 2 ; Pi ; Pr ; Pg ; Pb) + */ + getFgColor(): number; + + /** + * Gets a cell's background color number, this differs depending on what the + * color mode of the cell is: + * + * - Default: This should be 0, representing the default background color + * (CSI 49 m). + * - Palette: This is a number from 0 to 255 of ANSI colors + * (CSI 4(0-7) m, CSI 10(0-7) m, CSI 48 ; 5 ; 0-255 m). + * - RGB: A hex value representing a 'true color': 0xRRGGBB + * (CSI 4 8 ; 2 ; Pi ; Pr ; Pg ; Pb) + */ + getBgColor(): number; + + /** Whether the cell has the bold attribute (CSI 1 m). */ + isBold(): number; + /** Whether the cell has the inverse attribute (CSI 3 m). */ + isItalic(): number; + /** Whether the cell has the inverse attribute (CSI 2 m). */ + isDim(): number; + /** Whether the cell has the underline attribute (CSI 4 m). */ + isUnderline(): number; + /** Whether the cell has the inverse attribute (CSI 5 m). */ + isBlink(): number; + /** Whether the cell has the inverse attribute (CSI 7 m). */ + isInverse(): number; + /** Whether the cell has the inverse attribute (CSI 8 m). */ + isInvisible(): number; + + /** Whether the cell is using the RGB foreground color mode. */ + isFgRGB(): boolean; + /** Whether the cell is using the RGB background color mode. */ + isBgRGB(): boolean; + /** Whether the cell is using the palette foreground color mode. */ + isFgPalette(): boolean; + /** Whether the cell is using the palette background color mode. */ + isBgPalette(): boolean; + /** Whether the cell is using the default foreground color mode. */ + isFgDefault(): boolean; + /** Whether the cell is using the default background color mode. */ + isBgDefault(): boolean; + + /** Whether the cell has the default attribute (no color or style). */ + isAttributeDefault(): boolean; + } + + /** + * Data type to register a CSI, DCS or ESC callback in the parser + * in the form: + * ESC I..I F + * CSI Prefix P..P I..I F + * DCS Prefix P..P I..I F data_bytes ST + * + * with these rules/restrictions: + * - prefix can only be used with CSI and DCS + * - only one leading prefix byte is recognized by the parser + * before any other parameter bytes (P..P) + * - intermediate bytes are recognized up to 2 + * + * For custom sequences make sure to read ECMA-48 and the resources at + * vt100.net to not clash with existing sequences or reserved address space. + * General recommendations: + * - use private address space (see ECMA-48) + * - use max one intermediate byte (technically not limited by the spec, + * in practice there are no sequences with more than one intermediate byte, + * thus parsers might get confused with more intermediates) + * - test against other common emulators to check whether they escape/ignore + * the sequence correctly + * + * Notes: OSC command registration is handled differently (see addOscHandler) + * APC, PM or SOS is currently not supported. + */ + export interface IFunctionIdentifier { + /** + * Optional prefix byte, must be in range \x3c .. \x3f. + * Usable in CSI and DCS. + */ + prefix?: string; + /** + * Optional intermediate bytes, must be in range \x20 .. \x2f. + * Usable in CSI, DCS and ESC. + */ + intermediates?: string; + /** + * Final byte, must be in range \x40 .. \x7e for CSI and DCS, + * \x30 .. \x7e for ESC. + */ + final: string; + } + + /** + * Allows hooking into the parser for custom handling of escape sequences. + */ + export interface IParser { + /** + * Adds a handler for CSI escape sequences. + * @param id Specifies the function identifier under which the callback + * gets registered, e.g. {final: 'm'} for SGR. + * @param callback The function to handle the sequence. The callback is + * called with the numerical params. If the sequence has subparams the + * array will contain subarrays with their numercial values. + * Return true if the sequence was handled; false if we should try + * a previous handler (set by addCsiHandler or setCsiHandler). + * The most recently added handler is tried first. + * @return An IDisposable you can call to remove this handler. + */ + registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable; + + /** + * Adds a handler for DCS escape sequences. + * @param id Specifies the function identifier under which the callback + * gets registered, e.g. {intermediates: '$' final: 'q'} for DECRQSS. + * @param callback The function to handle the sequence. Note that the + * function will only be called once if the sequence finished sucessfully. + * There is currently no way to intercept smaller data chunks, data chunks + * will be stored up until the sequence is finished. Since DCS sequences + * are not limited by the amount of data this might impose a problem for + * big payloads. Currently xterm.js limits DCS payload to 10 MB + * which should give enough room for most use cases. + * The function gets the payload and numerical parameters as arguments. + * Return true if the sequence was handled; false if we should try + * a previous handler (set by addDcsHandler or setDcsHandler). + * The most recently added handler is tried first. + * @return An IDisposable you can call to remove this handler. + */ + registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable; + + /** + * Adds a handler for ESC escape sequences. + * @param id Specifies the function identifier under which the callback + * gets registered, e.g. {intermediates: '%' final: 'G'} for + * default charset selection. + * @param callback The function to handle the sequence. + * Return true if the sequence was handled; false if we should try + * a previous handler (set by addEscHandler or setEscHandler). + * The most recently added handler is tried first. + * @return An IDisposable you can call to remove this handler. + */ + registerEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable; + + /** + * Adds a handler for OSC escape sequences. + * @param ident The number (first parameter) of the sequence. + * @param callback The function to handle the sequence. Note that the + * function will only be called once if the sequence finished sucessfully. + * There is currently no way to intercept smaller data chunks, data chunks + * will be stored up until the sequence is finished. Since OSC sequences + * are not limited by the amount of data this might impose a problem for + * big payloads. Currently xterm.js limits OSC payload to 10 MB + * which should give enough room for most use cases. + * The callback is called with OSC data string. + * Return true if the sequence was handled; false if we should try + * a previous handler (set by addOscHandler or setOscHandler). + * The most recently added handler is tried first. + * @return An IDisposable you can call to remove this handler. + */ + registerOscHandler(ident: number, callback: (data: string) => boolean): IDisposable; + } + + /** + * (EXPERIMENTAL) Unicode version provider. + * Used to register custom Unicode versions with `Terminal.unicode.register`. + */ + export interface IUnicodeVersionProvider { + /** + * String indicating the Unicode version provided. + */ + readonly version: string; + + /** + * Unicode version dependent wcwidth implementation. + */ + wcwidth(codepoint: number): 0 | 1 | 2; + } + + /** + * (EXPERIMENTAL) Unicode handling interface. + */ + export interface IUnicodeHandling { + /** + * Register a custom Unicode version provider. + */ + register(provider: IUnicodeVersionProvider): void; + + /** + * Registered Unicode versions. + */ + readonly versions: ReadonlyArray; + + /** + * Getter/setter for active Unicode version. + */ + activeVersion: string; + } + + /** + * Terminal modes as set by SM/DECSET. + */ + export interface IModes { + /** + * Application Cursor Keys (DECCKM): `CSI ? 1 h` + */ + readonly applicationCursorKeysMode: boolean; + /** + * Application Keypad Mode (DECNKM): `CSI ? 6 6 h` + */ + readonly applicationKeypadMode: boolean; + /** + * Bracketed Paste Mode: `CSI ? 2 0 0 4 h` + */ + readonly bracketedPasteMode: boolean; + /** + * Insert Mode (IRM): `CSI 4 h` + */ + readonly insertMode: boolean; + /** + * Mouse Tracking, this can be one of the following: + * - none: This is the default value and can be reset with DECRST + * - x10: Send Mouse X & Y on button press `CSI ? 9 h` + * - vt200: Send Mouse X & Y on button press and release `CSI ? 1 0 0 0 h` + * - drag: Use Cell Motion Mouse Tracking `CSI ? 1 0 0 2 h` + * - any: Use All Motion Mouse Tracking `CSI ? 1 0 0 3 h` + */ + readonly mouseTrackingMode: 'none' | 'x10' | 'vt200' | 'drag' | 'any'; + /** + * Origin Mode (DECOM): `CSI ? 6 h` + */ + readonly originMode: boolean; + /** + * Reverse-wraparound Mode: `CSI ? 4 5 h` + */ + readonly reverseWraparoundMode: boolean; + /** + * Send FocusIn/FocusOut events: `CSI ? 1 0 0 4 h` + */ + readonly sendFocusMode: boolean; + /** + * Auto-Wrap Mode (DECAWM): `CSI ? 7 h` + */ + readonly wraparoundMode: boolean + } +} diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 210e354d9..3828b415a 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -1666,7 +1666,7 @@ declare module 'xterm' { */ readonly reverseWraparoundMode: boolean; /** - * Send FocusIn/FocusOut events: `CSI ? 1 0 0 3 h` + * Send FocusIn/FocusOut events: `CSI ? 1 0 0 4 h` */ readonly sendFocusMode: boolean; /** From bef865e1967637b0c07486b23cfc82ded14e27a2 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 16 Aug 2021 15:06:29 -0700 Subject: [PATCH 090/164] Add xterm api tests --- test/api/Terminal.api.ts | 92 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/test/api/Terminal.api.ts b/test/api/Terminal.api.ts index 75399b733..1599f3a21 100644 --- a/test/api/Terminal.api.ts +++ b/test/api/Terminal.api.ts @@ -562,6 +562,98 @@ describe('API Integration Tests', function(): void { }); }); + describe('modes', () => { + it('defaults', async () => { + await openTerminal(page); + assert.deepStrictEqual(await page.evaluate(`window.term.modes`), { + applicationCursorKeysMode: false, + applicationKeypadMode: false, + bracketedPasteMode: false, + insertMode: false, + mouseTrackingMode: 'none', + originMode: false, + reverseWraparoundMode: false, + sendFocusMode: false, + wraparoundMode: true + }); + }); + it('applicationCursorKeysMode', async () => { + await openTerminal(page); + await writeSync(page, '\\x1b[?1h'); + assert.strictEqual(await page.evaluate(`window.term.modes.applicationCursorKeysMode`), true); + await writeSync(page, '\\x1b[?1l'); + assert.strictEqual(await page.evaluate(`window.term.modes.applicationCursorKeysMode`), false); + }); + it('applicationKeypadMode', async () => { + await openTerminal(page); + await writeSync(page, '\\x1b[?66h'); + assert.strictEqual(await page.evaluate(`window.term.modes.applicationKeypadMode`), true); + await writeSync(page, '\\x1b[?66l'); + assert.strictEqual(await page.evaluate(`window.term.modes.applicationKeypadMode`), false); + }); + it('bracketedPasteMode', async () => { + await openTerminal(page); + await writeSync(page, '\\x1b[?2004h'); + assert.strictEqual(await page.evaluate(`window.term.modes.bracketedPasteMode`), true); + await writeSync(page, '\\x1b[?2004l'); + assert.strictEqual(await page.evaluate(`window.term.modes.bracketedPasteMode`), false); + }); + it('insertMode', async () => { + await openTerminal(page); + await writeSync(page, '\\x1b[4h'); + assert.strictEqual(await page.evaluate(`window.term.modes.insertMode`), true); + await writeSync(page, '\\x1b[4l'); + assert.strictEqual(await page.evaluate(`window.term.modes.insertMode`), false); + }); + it('mouseTrackingMode', async () => { + await openTerminal(page); + await writeSync(page, '\\x1b[?9h'); + assert.strictEqual(await page.evaluate(`window.term.modes.mouseTrackingMode`), 'x10'); + await writeSync(page, '\\x1b[?9l'); + assert.strictEqual(await page.evaluate(`window.term.modes.mouseTrackingMode`), 'none'); + await writeSync(page, '\\x1b[?1000h'); + assert.strictEqual(await page.evaluate(`window.term.modes.mouseTrackingMode`), 'vt200'); + await writeSync(page, '\\x1b[?1000l'); + assert.strictEqual(await page.evaluate(`window.term.modes.mouseTrackingMode`), 'none'); + await writeSync(page, '\\x1b[?1002h'); + assert.strictEqual(await page.evaluate(`window.term.modes.mouseTrackingMode`), 'drag'); + await writeSync(page, '\\x1b[?1002l'); + assert.strictEqual(await page.evaluate(`window.term.modes.mouseTrackingMode`), 'none'); + await writeSync(page, '\\x1b[?1003h'); + assert.strictEqual(await page.evaluate(`window.term.modes.mouseTrackingMode`), 'any'); + await writeSync(page, '\\x1b[?1003l'); + assert.strictEqual(await page.evaluate(`window.term.modes.mouseTrackingMode`), 'none'); + }); + it('originMode', async () => { + await openTerminal(page); + await writeSync(page, '\\x1b[?6h'); + assert.strictEqual(await page.evaluate(`window.term.modes.originMode`), true); + await writeSync(page, '\\x1b[?6l'); + assert.strictEqual(await page.evaluate(`window.term.modes.originMode`), false); + }); + it('reverseWraparoundMode', async () => { + await openTerminal(page); + await writeSync(page, '\\x1b[?45h'); + assert.strictEqual(await page.evaluate(`window.term.modes.reverseWraparoundMode`), true); + await writeSync(page, '\\x1b[?45l'); + assert.strictEqual(await page.evaluate(`window.term.modes.reverseWraparoundMode`), false); + }); + it('sendFocusMode', async () => { + await openTerminal(page); + await writeSync(page, '\\x1b[?1004h'); + assert.strictEqual(await page.evaluate(`window.term.modes.sendFocusMode`), true); + await writeSync(page, '\\x1b[?1004l'); + assert.strictEqual(await page.evaluate(`window.term.modes.sendFocusMode`), false); + }); + it('wraparoundMode', async () => { + await openTerminal(page); + await writeSync(page, '\\x1b[?7h'); + assert.strictEqual(await page.evaluate(`window.term.modes.wraparoundMode`), true); + await writeSync(page, '\\x1b[?7l'); + assert.strictEqual(await page.evaluate(`window.term.modes.wraparoundMode`), false); + }); + }); + it('dispose', async () => { await page.evaluate(` window.term = new Terminal(); From 6c834aecb4bc1e08e9710cf6cf54c90c23a69f1d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 16 Aug 2021 15:31:34 -0700 Subject: [PATCH 091/164] Serialize modes Fixes #3417 --- .../src/SerializeAddon.ts | 32 ++++++++++++ .../test/SerializeAddon.api.ts | 52 +++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index 5cd834b86..727807651 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -403,6 +403,35 @@ export class SerializeAddon implements ITerminalAddon { return handler.serialize(maxRows - correctRows, maxRows); } + private _serializeModes(terminal: Terminal): string { + let content = ''; + const modes = terminal.modes; + + // Default: false + if (modes.applicationCursorKeysMode) content += '\x1b[?1h'; + if (modes.applicationKeypadMode) content += '\x1b[?66h'; + if (modes.bracketedPasteMode) content += '\x1b[?2004h'; + if (modes.insertMode) content += '\x1b[4h'; + if (modes.originMode) content += '\x1b[?6h'; + if (modes.reverseWraparoundMode) content += '\x1b[?45h'; + if (modes.sendFocusMode) content += '\x1b[?1004h'; + + // Default: true + if (modes.wraparoundMode === false) content += '\x1b[?7l'; + + // Default: 'none' + if (modes.mouseTrackingMode !== 'none') { + switch (modes.mouseTrackingMode) { + case 'x10': content += '\x1b[?9h'; break; + case 'vt200': content += '\x1b[?1000h'; break; + case 'drag': content += '\x1b[?1002h'; break; + case 'any': content += '\x1b[?1003h'; break; + } + } + + return content; + } + public serialize(scrollback?: number): string { // TODO: Add combinedData support if (!this._terminal) { @@ -418,6 +447,9 @@ export class SerializeAddon implements ITerminalAddon { content += `\u001b[?1049h\u001b[H${alternativeScreenContent}`; } + // Modes + content += this._serializeModes(this._terminal); + return content; } diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index c8b7302f6..87f77f596 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -30,6 +30,12 @@ const testNormalScreenEqual = async (page: any, str: string): Promise => { assert.equal(JSON.stringify(originalBuffer), JSON.stringify(newBuffer)); }; +async function testSerializeEquals(writeContent: string, expectedSerialized: string): Promise { + await writeRawSync(page, writeContent); + const result = await page.evaluate(`serializeAddon.serialize();`) as string; + assert.strictEqual(result, expectedSerialized); +} + describe('SerializeAddon', () => { before(async function(): Promise { const browserType = getBrowserType(); @@ -479,6 +485,52 @@ describe('SerializeAddon', () => { await testNormalScreenEqual(page, lines.join('')); }); + + describe('handle modes', () => { + it('applicationCursorKeysMode', async () => { + await testSerializeEquals('test\u001b[?1h', 'test\u001b[?1h'); + await testSerializeEquals('\u001b[?1l', 'test'); + }); + it('applicationKeypadMode', async () => { + await testSerializeEquals('test\u001b[?66h', 'test\u001b[?66h'); + await testSerializeEquals('\u001b[?66l', 'test'); + }); + it('bracketedPasteMode', async () => { + await testSerializeEquals('test\u001b[?2004h', 'test\u001b[?2004h'); + await testSerializeEquals('\u001b[?2004l', 'test'); + }); + it('insertMode', async () => { + await testSerializeEquals('test\u001b[4h', 'test\u001b[4h'); + await testSerializeEquals('\u001b[4l', 'test'); + }); + it('mouseTrackingMode', async () => { + await testSerializeEquals('test\u001b[?9h', 'test\u001b[?9h'); + await testSerializeEquals('\u001b[?9l', 'test'); + await testSerializeEquals('\u001b[?1000h', 'test\u001b[?1000h'); + await testSerializeEquals('\u001b[?1000l', 'test'); + await testSerializeEquals('\u001b[?1002h', 'test\u001b[?1002h'); + await testSerializeEquals('\u001b[?1002l', 'test'); + await testSerializeEquals('\u001b[?1003h', 'test\u001b[?1003h'); + await testSerializeEquals('\u001b[?1003l', 'test'); + }); + it('originMode', async () => { + // origin mode moves cursor to (0,0) + await testSerializeEquals('test\u001b[?6h', 'test\u001b[4D\u001b[?6h'); + await testSerializeEquals('\u001b[?6l', 'test\u001b[4D'); + }); + it('reverseWraparoundMode', async () => { + await testSerializeEquals('test\u001b[?45h', 'test\u001b[?45h'); + await testSerializeEquals('\u001b[?45l', 'test'); + }); + it('sendFocusMode', async () => { + await testSerializeEquals('test\u001b[?1004h', 'test\u001b[?1004h'); + await testSerializeEquals('\u001b[?1004l', 'test'); + }); + it('wraparoundMode', async () => { + await testSerializeEquals('test\u001b[?7l', 'test\u001b[?7l'); + await testSerializeEquals('\u001b[?7h', 'test'); + }); + }); }); function newArray(initial: T | ((index: number) => T), count: number): T[] { From c1b4f4edb15f9b9a55dabf373156417dfcea8cd8 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 17 Aug 2021 04:41:44 -0700 Subject: [PATCH 092/164] Fix webgl access of core service --- addons/xterm-addon-webgl/src/WebglRenderer.ts | 2 +- .../xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/xterm-addon-webgl/src/WebglRenderer.ts b/addons/xterm-addon-webgl/src/WebglRenderer.ts index 9b75d1dea..29e97d6dc 100644 --- a/addons/xterm-addon-webgl/src/WebglRenderer.ts +++ b/addons/xterm-addon-webgl/src/WebglRenderer.ts @@ -60,7 +60,7 @@ export class WebglRenderer extends Disposable implements IRenderer { this._renderLayers = [ new LinkRenderLayer(this._core.screenElement!, 2, this._colors, this._core), - new CursorRenderLayer(this._core.screenElement!, 3, this._colors, this._onRequestRedraw) + new CursorRenderLayer(this._core.screenElement!, 3, this._colors, this._core, this._onRequestRedraw) ]; this.dimensions = { scaledCharWidth: 0, diff --git a/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts b/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts index 880896e02..912c23c96 100644 --- a/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts +++ b/addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts @@ -7,7 +7,7 @@ import { Terminal } from 'xterm'; import { BaseRenderLayer } from './BaseRenderLayer'; import { ICellData } from 'common/Types'; import { CellData } from 'common/buffer/CellData'; -import { IColorSet } from 'browser/Types'; +import { IColorSet, ITerminal } from 'browser/Types'; import { IRenderDimensions, IRequestRedrawEvent } from 'browser/renderer/Types'; import { IEventEmitter } from 'common/EventEmitter'; @@ -34,6 +34,7 @@ export class CursorRenderLayer extends BaseRenderLayer { container: HTMLElement, zIndex: number, colors: IColorSet, + private readonly _terminal: ITerminal, private _onRequestRefreshRowsEvent: IEventEmitter ) { super(container, 'cursor', zIndex, true, colors); @@ -120,7 +121,7 @@ export class CursorRenderLayer extends BaseRenderLayer { private _render(terminal: Terminal, triggeredByAnimationFrame: boolean): void { // Don't draw the cursor if it's hidden // TODO: Need to expose API for this - if (!(terminal as any)._core._coreService.isCursorInitialized || (terminal as any)._core._coreService.isCursorHidden) { + if (!this._terminal.coreService.isCursorInitialized || this._terminal.coreService.isCursorHidden) { this._clearCursor(); return; } From 280ce85b748cabd299fb2e1f848063979ba78ece Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 17 Aug 2021 04:50:29 -0700 Subject: [PATCH 093/164] Remove role=document from terminal element Part of microsoft/vscode#98918 --- src/browser/Terminal.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 004f23147..8072d6cbf 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -408,7 +408,6 @@ export class Terminal extends CoreTerminal implements ITerminal { this.element.classList.add('terminal'); this.element.classList.add('xterm'); this.element.setAttribute('tabindex', '0'); - this.element.setAttribute('role', 'document'); parent.appendChild(this.element); // Performance: Use a document fragment to build the terminal From 7c0a28eb59304f919f02ef8bd94efd2b172f0f25 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 17 Aug 2021 04:54:44 -0700 Subject: [PATCH 094/164] Call out xterm-headless in main readme Fixes #3412 --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 479c81133..720e703cf 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,10 @@ We also partially support *Internet Explorer 11*, meaning xterm.js should work f Xterm.js works seamlessly in [Electron](https://electronjs.org/) apps and may even work on earlier versions of the browsers. These are the versions we strive to keep working. +### Node.js Support + +We also publish [`xterm-headless`](https://www.npmjs.com/package/xterm-headless) which is a stripped down version of xterm.js that runs in Node.js. An example use case for this is to keep track of a terminal's state where the process is running and using the serialize addon so it can get all state restored upon reconnection. + ## API The full API for xterm.js is contained within the [TypeScript declaration file](https://github.com/xtermjs/xterm.js/blob/master/typings/xterm.d.ts), use the branch/tag picker in GitHub (`w`) to navigate to the correct version of the API. From 7a2621f6abbb58d80e77d213182374bbc4b3199a Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 17 Aug 2021 05:48:52 -0700 Subject: [PATCH 095/164] Make serialize and unicode11 compatible with node Fixes #3410 Fixes #3411 --- addons/xterm-addon-serialize/src/SerializeAddon.ts | 1 + addons/xterm-addon-serialize/webpack.config.js | 3 ++- addons/xterm-addon-unicode11/src/Unicode11Addon.ts | 1 + addons/xterm-addon-unicode11/webpack.config.js | 3 ++- headless/package.json | 9 --------- 5 files changed, 6 insertions(+), 11 deletions(-) delete mode 100644 headless/package.json diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index 0caaaa039..0cf474e60 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -7,6 +7,7 @@ import { Terminal, ITerminalAddon, IBuffer, IBufferCell } from 'xterm'; + function constrain(value: number, low: number, high: number): number { return Math.max(low, Math.min(value, high)); } diff --git a/addons/xterm-addon-serialize/webpack.config.js b/addons/xterm-addon-serialize/webpack.config.js index 4cabbad91..7c0ccd016 100644 --- a/addons/xterm-addon-serialize/webpack.config.js +++ b/addons/xterm-addon-serialize/webpack.config.js @@ -25,7 +25,8 @@ module.exports = { filename: mainFile, path: path.resolve('./lib'), library: addonName, - libraryTarget: 'umd' + libraryTarget: 'umd', + globalObject: 'this' }, mode: 'production' }; diff --git a/addons/xterm-addon-unicode11/src/Unicode11Addon.ts b/addons/xterm-addon-unicode11/src/Unicode11Addon.ts index cb8c9c563..d4ddf77ee 100644 --- a/addons/xterm-addon-unicode11/src/Unicode11Addon.ts +++ b/addons/xterm-addon-unicode11/src/Unicode11Addon.ts @@ -8,6 +8,7 @@ import { Terminal, ITerminalAddon } from 'xterm'; import { UnicodeV11 } from './UnicodeV11'; + export class Unicode11Addon implements ITerminalAddon { public activate(terminal: Terminal): void { terminal.unicode.register(new UnicodeV11()); diff --git a/addons/xterm-addon-unicode11/webpack.config.js b/addons/xterm-addon-unicode11/webpack.config.js index 66a83a2fb..10c0adc3c 100644 --- a/addons/xterm-addon-unicode11/webpack.config.js +++ b/addons/xterm-addon-unicode11/webpack.config.js @@ -32,7 +32,8 @@ module.exports = { filename: mainFile, path: path.resolve('./lib'), library: addonName, - libraryTarget: 'umd' + libraryTarget: 'umd', + globalObject: 'this' }, mode: 'production' }; diff --git a/headless/package.json b/headless/package.json deleted file mode 100644 index d53761e7a..000000000 --- a/headless/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "xterm-headless", - "description": "A headless terminal component that runs in Node.js", - "version": "4.13.0-alpha3", - "main": "lib-headless/xterm-headless.js", - "types": "typings/xterm-headless.d.ts", - "repository": "https://github.com/xtermjs/xterm.js", - "license": "MIT" -} \ No newline at end of file From 2b3c7639824468067f05009f60a091b5f047b4f6 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 17 Aug 2021 07:42:47 -0700 Subject: [PATCH 096/164] Clean up mixed weight characters --- src/browser/renderer/BoxAndBlockCharacters.ts | 122 ++++++++---------- 1 file changed, 54 insertions(+), 68 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 23e769638..7882d03e5 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -90,15 +90,6 @@ export const boxDrawingBoxes: { [index: string]: any } = { '\u{1FB97}': [{ x: 0, y: 2, w: 8, h: 2 }, { x: 0, y: 6, w: 8, h: 2 }] }; -const yAxis = `M.5,0 L.5,1`; -const xAxis = `M0,.5 L1,.5`; -const bottomYAxisFromBottom = `M.5,1 L.5,.5`; -const bottomYAxisFromMiddle = `M.5,.5 L.5,1`; -const topYAxisFromTop = `M.5,0 L.5,.5`; -const topYAxisFromMiddle = `M.5,0 L.5,.5`; -const rightMiddleXAxis = `M.5,.5 L1,.5`; -const leftMiddleXAxis = `M.5,.5 L0,.5`; - const enum Shapes { /** │ */ TOP_TO_BOTTOM = 'M.5,0 L.5,1', /** ─ */ LEFT_TO_RIGHT = 'M0,.5 L1,.5', @@ -108,8 +99,8 @@ const enum Shapes { /** ┐ */ LEFT_TO_BOTTOM = 'M0,.5 L.5,.5 L.5,1', /** ┌ */ RIGHT_TO_BOTTOM = 'M0.5,1 L.5,.5 L1,.5', - /** ╵ */ MIDDLE_TO_TOP = 'M.5,.5 L0,.5', - /** ╴ */ MIDDLE_TO_LEFT = 'M.5,.5 L.5,0', + /** ╵ */ MIDDLE_TO_TOP = 'M.5,.5 L.5,0', + /** ╴ */ MIDDLE_TO_LEFT = 'M.5,.5 L0,.5', /** ╶ */ MIDDLE_TO_RIGHT = 'M.5,.5 L1,.5', /** ╷ */ MIDDLE_TO_BOTTOM = 'M.5,.5 L.5,1', @@ -167,10 +158,6 @@ export const boxCharacters: { [character: string]: { [fontWeight: number]: strin '╷': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM }, '╻': { [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, - // Mixed normal/bold - '┍': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT }, - '┎': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, - // Double border '═': { [Style.NORMAL]: (xp, yp) => `M0,${.5 - yp} L1,${.5 - yp} M0,${.5 + yp} L1,${.5 + yp}` }, '║': { [Style.NORMAL]: (xp, yp) => `M${.5 - xp},0 L${.5 - xp},1 M${.5 + xp},0 L${.5 + xp},1` }, @@ -208,54 +195,56 @@ export const boxCharacters: { [character: string]: { [fontWeight: number]: strin '╳': { [Style.NORMAL]: 'M1,0 L0,1 M0,0 L1,1' }, // Mixed weight - '┑': { [Style.NORMAL]: `${bottomYAxisFromBottom}`, [Style.BOLD]: `${leftMiddleXAxis}` }, - '┒': { [Style.NORMAL]: `${leftMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom}` }, - '┕': { [Style.NORMAL]: `${topYAxisFromTop}`, [Style.BOLD]: `${rightMiddleXAxis}` }, - '┖': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromTop}` }, - '┙': { [Style.NORMAL]: `${topYAxisFromTop}`, [Style.BOLD]: `${leftMiddleXAxis}` }, - '┚': { [Style.NORMAL]: `${leftMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromTop}` }, - '┝': { [Style.NORMAL]: `${yAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, - '┞': { [Style.NORMAL]: `${bottomYAxisFromMiddle} ${rightMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromTop}` }, - '┟': { [Style.NORMAL]: `${topYAxisFromMiddle} ${rightMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom}` }, - '┠': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${yAxis}` }, - '┡': { [Style.NORMAL]: `${bottomYAxisFromBottom}`, [Style.BOLD]: `${topYAxisFromMiddle} ${rightMiddleXAxis}` }, - '┢': { [Style.NORMAL]: `${topYAxisFromMiddle}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` }, - '┥': { [Style.NORMAL]: `${yAxis}`, [Style.BOLD]: `${leftMiddleXAxis}` }, - '┦': { [Style.NORMAL]: `${bottomYAxisFromMiddle} ${leftMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromTop}` }, - '┧': { [Style.NORMAL]: `${topYAxisFromMiddle}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` }, - '┨': { [Style.NORMAL]: `${leftMiddleXAxis}`, [Style.BOLD]: `${yAxis}` }, - '┩': { [Style.NORMAL]: `${bottomYAxisFromMiddle}`, [Style.BOLD]: `${topYAxisFromMiddle} ${leftMiddleXAxis}` }, - '┪': { [Style.NORMAL]: `${topYAxisFromMiddle}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` }, - '┭': { [Style.NORMAL]: `${bottomYAxisFromBottom} ${rightMiddleXAxis}`, [Style.BOLD]: `${leftMiddleXAxis}` }, - '┮': { [Style.NORMAL]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, - '┯': { [Style.NORMAL]: `${bottomYAxisFromBottom}`, [Style.BOLD]: `${leftMiddleXAxis} ${rightMiddleXAxis}` }, - '┰': { [Style.NORMAL]: `${xAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom}` }, - '┱': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` }, - '┲': { [Style.NORMAL]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, - '┵': { [Style.NORMAL]: `${topYAxisFromMiddle} ${rightMiddleXAxis}`, [Style.BOLD]: `${leftMiddleXAxis}` }, - '┶': { [Style.NORMAL]: `${topYAxisFromMiddle} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, - '┷': { [Style.NORMAL]: `${topYAxisFromMiddle}`, [Style.BOLD]: `${leftMiddleXAxis} ${rightMiddleXAxis}` }, - '┸': { [Style.NORMAL]: `${xAxis}`, [Style.BOLD]: `${topYAxisFromMiddle}` }, - '┹': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromMiddle} ${leftMiddleXAxis}` }, - '┺': { [Style.NORMAL]: `${topYAxisFromMiddle} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, - '┽': { [Style.NORMAL]: `${yAxis} ${rightMiddleXAxis}`, [Style.BOLD]: `${leftMiddleXAxis}` }, - '┾': { [Style.NORMAL]: `${yAxis} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, - '┿': { [Style.NORMAL]: `${yAxis}`, [Style.BOLD]: `${leftMiddleXAxis} ${rightMiddleXAxis}` }, - '╀': { [Style.NORMAL]: `${xAxis}`, [Style.BOLD]: `${yAxis}` }, - '╁': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${yAxis} ${leftMiddleXAxis}` }, - '╂': { [Style.NORMAL]: `${yAxis} ${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, - '╃': { [Style.NORMAL]: `${bottomYAxisFromBottom} ${rightMiddleXAxis}`, [Style.BOLD]: `${topYAxisFromTop} ${leftMiddleXAxis}` }, - '╄': { [Style.NORMAL]: `${topYAxisFromTop} ${leftMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` }, - '╅': { [Style.NORMAL]: `${topYAxisFromTop} ${rightMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${leftMiddleXAxis}` }, - '╆': { [Style.NORMAL]: `${topYAxisFromTop} ${leftMiddleXAxis}`, [Style.BOLD]: `${bottomYAxisFromBottom} ${rightMiddleXAxis}` }, - '╇': { [Style.NORMAL]: `${bottomYAxisFromBottom}`, [Style.BOLD]: `${leftMiddleXAxis} ${topYAxisFromTop} ${rightMiddleXAxis}` }, - '╈': { [Style.NORMAL]: `${topYAxisFromTop}`, [Style.BOLD]: `${leftMiddleXAxis} ${bottomYAxisFromBottom} ${rightMiddleXAxis}` }, - '╉': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${leftMiddleXAxis} ${yAxis}` }, - '╊': { [Style.NORMAL]: `${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis} ${yAxis}` }, - '╼': { [Style.NORMAL]: `${leftMiddleXAxis}`, [Style.BOLD]: `${rightMiddleXAxis}` }, - '╽': { [Style.NORMAL]: `${topYAxisFromMiddle}`, [Style.BOLD]: `${bottomYAxisFromBottom}` }, - '╾': { [Style.NORMAL]: `${rightMiddleXAxis}`, [Style.BOLD]: `${leftMiddleXAxis}` }, - '╿': { [Style.NORMAL]: `${bottomYAxisFromBottom}`, [Style.BOLD]: `${topYAxisFromMiddle}` }, + '╼': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT }, + '╽': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, + '╾': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT }, + '╿': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_TOP }, + '┍': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT }, + '┎': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, + '┑': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT }, + '┒': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, + '┕': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT }, + '┖': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_TOP }, + '┙': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT }, + '┚': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: Shapes.MIDDLE_TO_TOP }, + '┝': { [Style.NORMAL]: Shapes.TOP_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT }, + '┞': { [Style.NORMAL]: Shapes.RIGHT_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_TOP }, + '┟': { [Style.NORMAL]: Shapes.TOP_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, + '┠': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: Shapes.TOP_TO_BOTTOM }, + '┡': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: Shapes.TOP_TO_RIGHT }, + '┢': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP, [Style.BOLD]: Shapes.RIGHT_TO_BOTTOM }, + '┥': { [Style.NORMAL]: Shapes.TOP_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT }, + '┦': { [Style.NORMAL]: Shapes.LEFT_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_TOP }, + '┧': { [Style.NORMAL]: Shapes.TOP_TO_LEFT, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, + '┨': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: Shapes.TOP_TO_BOTTOM }, + '┩': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: Shapes.TOP_TO_LEFT }, + '┪': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP, [Style.BOLD]: Shapes.LEFT_TO_BOTTOM }, + '┭': { [Style.NORMAL]: Shapes.RIGHT_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT }, + '┮': { [Style.NORMAL]: Shapes.LEFT_TO_BOTTOM, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT }, + '┯': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: Shapes.LEFT_TO_RIGHT }, + '┰': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, + '┱': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: Shapes.LEFT_TO_BOTTOM }, + '┲': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: Shapes.RIGHT_TO_BOTTOM }, + '┵': { [Style.NORMAL]: Shapes.TOP_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT }, + '┶': { [Style.NORMAL]: Shapes.TOP_TO_LEFT, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT }, + '┷': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP, [Style.BOLD]: Shapes.LEFT_TO_RIGHT }, + '┸': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT, [Style.BOLD]: Shapes.MIDDLE_TO_TOP }, + '┹': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: Shapes.TOP_TO_LEFT }, + '┺': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: Shapes.TOP_TO_RIGHT }, + '┽': { [Style.NORMAL]: `${Shapes.TOP_TO_BOTTOM} ${Shapes.MIDDLE_TO_RIGHT}`, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT }, + '┾': { [Style.NORMAL]: `${Shapes.TOP_TO_BOTTOM} ${Shapes.MIDDLE_TO_LEFT}`, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT }, + '┿': { [Style.NORMAL]: Shapes.TOP_TO_BOTTOM, [Style.BOLD]: Shapes.LEFT_TO_RIGHT }, + '╀': { [Style.NORMAL]: `${Shapes.LEFT_TO_RIGHT} ${Shapes.MIDDLE_TO_BOTTOM}`, [Style.BOLD]: Shapes.TOP_TO_BOTTOM }, + '╁': { [Style.NORMAL]: `${Shapes.MIDDLE_TO_TOP} ${Shapes.LEFT_TO_RIGHT}`, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, + '╂': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT, [Style.BOLD]: Shapes.TOP_TO_BOTTOM }, + '╃': { [Style.NORMAL]: Shapes.RIGHT_TO_BOTTOM, [Style.BOLD]: Shapes.TOP_TO_LEFT }, + '╄': { [Style.NORMAL]: Shapes.LEFT_TO_BOTTOM, [Style.BOLD]: Shapes.TOP_TO_RIGHT }, + '╅': { [Style.NORMAL]: Shapes.TOP_TO_RIGHT, [Style.BOLD]: Shapes.LEFT_TO_BOTTOM }, + '╆': { [Style.NORMAL]: Shapes.TOP_TO_LEFT, [Style.BOLD]: Shapes.RIGHT_TO_BOTTOM }, + '╇': { [Style.NORMAL]: Shapes.MIDDLE_TO_BOTTOM, [Style.BOLD]: `${Shapes.MIDDLE_TO_TOP} ${Shapes.LEFT_TO_RIGHT}` }, + '╈': { [Style.NORMAL]: Shapes.MIDDLE_TO_TOP, [Style.BOLD]: `${Shapes.LEFT_TO_RIGHT} ${Shapes.MIDDLE_TO_BOTTOM}` }, + '╉': { [Style.NORMAL]: Shapes.MIDDLE_TO_RIGHT, [Style.BOLD]: `${Shapes.TOP_TO_BOTTOM} ${Shapes.MIDDLE_TO_LEFT}` }, + '╊': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: `${Shapes.TOP_TO_BOTTOM} ${Shapes.MIDDLE_TO_RIGHT}` }, // Dashed // TODO: Spacing dashes evenly, use 1/2 padding on each edge so the line is continuous @@ -324,9 +313,6 @@ function clamp(value: number, max: number, min: number = 0): number { } const instructionMap: { [index: string]: any } = { - 'M': (ctx: CanvasRenderingContext2D, x: number, y: number) => { - ctx.moveTo(x, y); }, - 'L': (ctx: CanvasRenderingContext2D, x: number, y: number) => { - ctx.lineTo(x, y); - } + 'M': (ctx: CanvasRenderingContext2D, x: number, y: number) => ctx.moveTo(x, y), + 'L': (ctx: CanvasRenderingContext2D, x: number, y: number) => ctx.lineTo(x, y) }; From f43ae16a47d6062face1de48504d08f061a40797 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 17 Aug 2021 07:57:32 -0700 Subject: [PATCH 097/164] Implement curved lines --- src/browser/renderer/BoxAndBlockCharacters.ts | 71 ++++++++++++------- 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 7882d03e5..42608295c 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -248,18 +248,24 @@ export const boxCharacters: { [character: string]: { [fontWeight: number]: strin // Dashed // TODO: Spacing dashes evenly, use 1/2 padding on each edge so the line is continuous - '╌': { [Style.NORMAL]: Shapes.TWO_DASHES_HORIZONTAL }, - '╍': { [Style.BOLD]: Shapes.TWO_DASHES_HORIZONTAL }, - '┄': { [Style.NORMAL]: Shapes.THREE_DASHES_HORIZONTAL }, - '┅': { [Style.BOLD]: Shapes.THREE_DASHES_HORIZONTAL }, - '┈': { [Style.NORMAL]: Shapes.FOUR_DASHES_HORIZONTAL }, - '┉': { [Style.BOLD]: Shapes.FOUR_DASHES_HORIZONTAL }, + '╌': { [Style.NORMAL]: Shapes.TWO_DASHES_HORIZONTAL }, + '╍': { [Style.BOLD]: Shapes.TWO_DASHES_HORIZONTAL }, + '┄': { [Style.NORMAL]: Shapes.THREE_DASHES_HORIZONTAL }, + '┅': { [Style.BOLD]: Shapes.THREE_DASHES_HORIZONTAL }, + '┈': { [Style.NORMAL]: Shapes.FOUR_DASHES_HORIZONTAL }, + '┉': { [Style.BOLD]: Shapes.FOUR_DASHES_HORIZONTAL }, '╎': { [Style.NORMAL]: Shapes.TWO_DASHES_VERTICAL }, '╏': { [Style.BOLD]: Shapes.TWO_DASHES_VERTICAL }, '┆': { [Style.NORMAL]: Shapes.THREE_DASHES_VERTICAL }, - '┇': { [Style.BOLD]: Shapes.THREE_DASHES_VERTICAL }, + '┇': { [Style.BOLD]: Shapes.THREE_DASHES_VERTICAL }, '┊': { [Style.NORMAL]: Shapes.FOUR_DASHES_VERTICAL }, - '┋': { [Style.BOLD]: Shapes.FOUR_DASHES_VERTICAL } + '┋': { [Style.BOLD]: Shapes.FOUR_DASHES_VERTICAL }, + + // Curved + '╭': { [Style.NORMAL]: 'C.5,1,.5,.5,1,.5' }, + '╮': { [Style.NORMAL]: 'C.5,1,.5,.5,0,.5' }, + '╯': { [Style.NORMAL]: 'C.5,0,.5,.5,0,.5' }, + '╰': { [Style.NORMAL]: 'C.5,0,.5,.5,1,.5' } }; export function drawBoxChar(ctx: CanvasRenderingContext2D, c: string, xOffset: number, yOffset: number, cellWidth: number, cellHeight: number): void { @@ -285,23 +291,11 @@ export function drawBoxChar(ctx: CanvasRenderingContext2D, c: string, xOffset: n console.error(`Could not find drawing instructions for "${type}"`); continue; } - const coords: string[] = instruction.substring(1).split(','); - if (!coords[0] || !coords[1]) { + const args: string[] = instruction.substring(1).split(','); + if (!args[0] || !args[1]) { continue; } - let x = Number.parseFloat(coords[0].toString()) || Number.parseInt(coords[0].toString()); - let y = Number.parseFloat(coords[1].toString()) || Number.parseInt(coords[1].toString()); - - x *= cellWidth; - y *= cellHeight; - - if (y !== 0) { - y = clamp(Math.round(y + .5) - .5, cellHeight, 0); - } - if (x !== 0) { - x = clamp(Math.round(x + .5) - .5, cellWidth, 0); - } - f(ctx, xOffset + x, yOffset + y); + f(ctx, translateArgs(args, cellWidth, cellHeight, xOffset, yOffset)); } ctx.stroke(); ctx.closePath(); @@ -313,6 +307,33 @@ function clamp(value: number, max: number, min: number = 0): number { } const instructionMap: { [index: string]: any } = { - 'M': (ctx: CanvasRenderingContext2D, x: number, y: number) => ctx.moveTo(x, y), - 'L': (ctx: CanvasRenderingContext2D, x: number, y: number) => ctx.lineTo(x, y) + 'C': (ctx: CanvasRenderingContext2D, args: number[]) => ctx.bezierCurveTo(args[0], args[1], args[2], args[3], args[4], args[5]), + 'L': (ctx: CanvasRenderingContext2D, args: number[]) => ctx.lineTo(args[0], args[1]), + 'M': (ctx: CanvasRenderingContext2D, args: number[]) => ctx.moveTo(args[0], args[1]) }; + +function translateArgs(args: string[], cellWidth: number, cellHeight: number, xOffset: number, yOffset: number): number[] { + const result = args.map(e => parseFloat(e) || parseInt(e)); + + if (result.length < 2) { + throw new Error('Too few arguments for instruction'); + } + + for (let x = 0; x < result.length; x += 2) { + result[x] *= cellWidth; + if (result[x] !== 0) { + result[x] = clamp(Math.round(result[x] + 0.5) - 0.5, cellWidth, 0); + } + result[x] += xOffset; + } + + for (let y = 1; y < result.length; y += 2) { + result[y] *= cellHeight; + if (result[y] !== 0) { + result[y] = clamp(Math.round(result[y] + 0.5) - 0.5, cellHeight, 0); + } + result[y] += yOffset; + } + + return result; +} From fd25ee0127c4b88421723ab212af0313c20fef4b Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 17 Aug 2021 08:02:19 -0700 Subject: [PATCH 098/164] Add some doc comments --- src/browser/renderer/BoxAndBlockCharacters.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 42608295c..48645d037 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -125,6 +125,7 @@ const enum Style { } // TODO: Tweak normal and bold weights +// This contains the definitions of all box drawing characters as SVG paths (ie. the svg d attribute) export const boxCharacters: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } } = { // Uniform normal and bold '─': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT }, @@ -320,18 +321,26 @@ function translateArgs(args: string[], cellWidth: number, cellHeight: number, xO } for (let x = 0; x < result.length; x += 2) { + // Translate from 0-1 to 0-cellWidth result[x] *= cellWidth; + // Ensure coordinate doesn't escape cell bounds and round to the nearest 0.5 to ensure a crisp + // line at 100% devicePixelRatio if (result[x] !== 0) { result[x] = clamp(Math.round(result[x] + 0.5) - 0.5, cellWidth, 0); } + // Apply the cell's offset (ie. x*cellWidth) result[x] += xOffset; } for (let y = 1; y < result.length; y += 2) { + // Translate from 0-1 to 0-cellHeight result[y] *= cellHeight; + // Ensure coordinate doesn't escape cell bounds and round to the nearest 0.5 to ensure a crisp + // line at 100% devicePixelRatio if (result[y] !== 0) { result[y] = clamp(Math.round(result[y] + 0.5) - 0.5, cellHeight, 0); } + // Apply the cell's offset (ie. x*cellHeight) result[y] += yOffset; } From 9269e91c49de1c70b4fcb46d915fab862782d49e Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 17 Aug 2021 08:04:17 -0700 Subject: [PATCH 099/164] Make bold triple normal weight so 1 dpr = 3px bold --- src/browser/renderer/BoxAndBlockCharacters.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 48645d037..af2391911 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -121,10 +121,9 @@ const enum Shapes { const enum Style { NORMAL = 1, - BOLD = 2 + BOLD = 3 } -// TODO: Tweak normal and bold weights // This contains the definitions of all box drawing characters as SVG paths (ie. the svg d attribute) export const boxCharacters: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } } = { // Uniform normal and bold From bcfbbb481c5608aabd1079957e56f27b9b73b89c Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 17 Aug 2021 08:14:46 -0700 Subject: [PATCH 100/164] Correct horizontal dash and a mixed weight char --- src/browser/renderer/BoxAndBlockCharacters.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index af2391911..030c06e8c 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -111,12 +111,12 @@ const enum Shapes { /** ┼ */ CROSS = 'M0,.5 L1,.5 M.5,0 L.5,1', - /** ╌ */ TWO_DASHES_HORIZONTAL = 'M.1,.5 L.45,.5 M.55,.5 L.9,.5', + /** ╌ */ TWO_DASHES_HORIZONTAL = 'M.1,.5 L.4,.5 M.6,.5 L.9,.5', /** ┄ */ THREE_DASHES_HORIZONTAL = 'M.052,.5 L.316,.5 M.0.421,.5 L.6315,.5 M.684,.5 L.947,.5', /** ┉ */ FOUR_DASHES_HORIZONTAL = 'M.0588,.5 L.235,.5 M.294,.5 L.4705,.5 M.529,.5 L.7058,.5 M.765,.5 L.947,.5', - /** ╌ */ TWO_DASHES_VERTICAL = 'M.5,0 T.5,.45 M.5,.55 T.5,1', - /** ┄ */ THREE_DASHES_VERTICAL = 'M.5,.052 L.5,.316 M.5,.0.368 L.5.632 M.5,.684 L.5,.947', - /** ┉ */ FOUR_DASHES_VERTICAL = 'M.5,.0588 L.5,.235 M.5,.294 L.5,.4705 29 L.5,.7058 M.5,.765 L.5,.947', + /** ╎ */ TWO_DASHES_VERTICAL = 'M.5,.1 T.5,.4 M.5,.6 T.5,.9', + /** ┆ */ THREE_DASHES_VERTICAL = 'M.5,.052 L.5,.316 M.5,.0.368 L.5.632 M.5,.684 L.5,.947', + /** ┊ */ FOUR_DASHES_VERTICAL = 'M.5,.0588 L.5,.235 M.5,.294 L.5,.4705 29 L.5,.7058 M.5,.765 L.5,.947', } const enum Style { @@ -234,7 +234,7 @@ export const boxCharacters: { [character: string]: { [fontWeight: number]: strin '┽': { [Style.NORMAL]: `${Shapes.TOP_TO_BOTTOM} ${Shapes.MIDDLE_TO_RIGHT}`, [Style.BOLD]: Shapes.MIDDLE_TO_LEFT }, '┾': { [Style.NORMAL]: `${Shapes.TOP_TO_BOTTOM} ${Shapes.MIDDLE_TO_LEFT}`, [Style.BOLD]: Shapes.MIDDLE_TO_RIGHT }, '┿': { [Style.NORMAL]: Shapes.TOP_TO_BOTTOM, [Style.BOLD]: Shapes.LEFT_TO_RIGHT }, - '╀': { [Style.NORMAL]: `${Shapes.LEFT_TO_RIGHT} ${Shapes.MIDDLE_TO_BOTTOM}`, [Style.BOLD]: Shapes.TOP_TO_BOTTOM }, + '╀': { [Style.NORMAL]: `${Shapes.LEFT_TO_RIGHT} ${Shapes.MIDDLE_TO_BOTTOM}`, [Style.BOLD]: Shapes.MIDDLE_TO_TOP }, '╁': { [Style.NORMAL]: `${Shapes.MIDDLE_TO_TOP} ${Shapes.LEFT_TO_RIGHT}`, [Style.BOLD]: Shapes.MIDDLE_TO_BOTTOM }, '╂': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT, [Style.BOLD]: Shapes.TOP_TO_BOTTOM }, '╃': { [Style.NORMAL]: Shapes.RIGHT_TO_BOTTOM, [Style.BOLD]: Shapes.TOP_TO_LEFT }, From ca88476934de016346e2bc57336d7e512631b81a Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 17 Aug 2021 08:48:23 -0700 Subject: [PATCH 101/164] Improve spacing of dash characters --- src/browser/renderer/BoxAndBlockCharacters.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 030c06e8c..ac37c761c 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -111,12 +111,12 @@ const enum Shapes { /** ┼ */ CROSS = 'M0,.5 L1,.5 M.5,0 L.5,1', - /** ╌ */ TWO_DASHES_HORIZONTAL = 'M.1,.5 L.4,.5 M.6,.5 L.9,.5', - /** ┄ */ THREE_DASHES_HORIZONTAL = 'M.052,.5 L.316,.5 M.0.421,.5 L.6315,.5 M.684,.5 L.947,.5', - /** ┉ */ FOUR_DASHES_HORIZONTAL = 'M.0588,.5 L.235,.5 M.294,.5 L.4705,.5 M.529,.5 L.7058,.5 M.765,.5 L.947,.5', - /** ╎ */ TWO_DASHES_VERTICAL = 'M.5,.1 T.5,.4 M.5,.6 T.5,.9', - /** ┆ */ THREE_DASHES_VERTICAL = 'M.5,.052 L.5,.316 M.5,.0.368 L.5.632 M.5,.684 L.5,.947', - /** ┊ */ FOUR_DASHES_VERTICAL = 'M.5,.0588 L.5,.235 M.5,.294 L.5,.4705 29 L.5,.7058 M.5,.765 L.5,.947', + /** ╌ */ TWO_DASHES_HORIZONTAL = 'M.1,.5 L.4,.5 M.6,.5 L.9,.5', // .2 empty, .3 filled + /** ┄ */ THREE_DASHES_HORIZONTAL = 'M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5', // .1333 empty, .2 filled + /** ┉ */ FOUR_DASHES_HORIZONTAL = 'M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5', // .1 empty, .15 filled + /** ╎ */ TWO_DASHES_VERTICAL = 'M.5,.1 L.5,.4 M.5,.6 L.5,.9', + /** ┆ */ THREE_DASHES_VERTICAL = 'M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333', + /** ┊ */ FOUR_DASHES_VERTICAL = 'M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95', } const enum Style { @@ -171,7 +171,7 @@ export const boxCharacters: { [character: string]: { [fontWeight: number]: strin '╙': { [Style.NORMAL]: (xp, yp) => `M1,.5 L${.5 - xp},.5 L${.5 - xp},0 M${.5 + xp},.5 L${.5 + xp},0` }, '╚': { [Style.NORMAL]: (xp, yp) => `M1,${.5 - yp} L${.5 + xp},${.5 - yp} L${.5 + xp},0 M1,${.5 + yp} L${.5 - xp},${.5 + yp} L${.5 - xp},0` }, '╛': { [Style.NORMAL]: (xp, yp) => `M0,${.5 + yp} L.5,${.5 + yp} L.5,0 M0,${.5 - yp} L.5,${.5 - yp}` }, - '╜': { [Style.NORMAL]: (xp, yp) => `M0,.5 L${.5 + xp},.5 L${.5 + xp},0 M${.5 - xp},.5 L${.5 - xp},0 ` }, + '╜': { [Style.NORMAL]: (xp, yp) => `M0,.5 L${.5 + xp},.5 L${.5 + xp},0 M${.5 - xp},.5 L${.5 - xp},0` }, '╝': { [Style.NORMAL]: (xp, yp) => `M0,${.5 - yp} L${.5 - xp},${.5 - yp} L${.5 - xp},0 M0,${.5 + yp} L${.5 + xp},${.5 + yp} L${.5 + xp},0` }, '╞': { [Style.NORMAL]: (xp, yp) => `${Shapes.TOP_TO_BOTTOM} M.5,${.5 - yp} L1,${.5 - yp} M.5,${.5 + yp} L1,${.5 + yp}` }, '╟': { [Style.NORMAL]: (xp, yp) => `M${.5 - xp},0 L${.5 - xp},1 M${.5 + xp},0 L${.5 + xp},1 M${.5 + xp},.5 L1,.5` }, From f1849cafafe01df5f153aefc02f2eb8d03325148 Mon Sep 17 00:00:00 2001 From: Samuel Sampson Date: Tue, 17 Aug 2021 20:48:31 +0000 Subject: [PATCH 102/164] Introduce IRenderDebouncer interface, unifying RenderDebouncer and TimeBasedDebouncer types --- src/browser/AccessibilityManager.ts | 4 ++-- src/browser/RenderDebouncer.ts | 4 ++-- src/browser/TimeBasedDebouncer.ts | 4 ++-- src/browser/Types.d.ts | 4 ++++ src/browser/services/RenderService.ts | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/browser/AccessibilityManager.ts b/src/browser/AccessibilityManager.ts index 160aa3fcc..1be3342d7 100644 --- a/src/browser/AccessibilityManager.ts +++ b/src/browser/AccessibilityManager.ts @@ -4,7 +4,7 @@ */ import * as Strings from 'browser/LocalizableStrings'; -import { ITerminal } from 'browser/Types'; +import { ITerminal, IRenderDebouncer } from 'browser/Types'; import { IBuffer } from 'common/buffer/Types'; import { isMac } from 'common/Platform'; import { TimeBasedDebouncer } from 'browser/TimeBasedDebouncer'; @@ -28,7 +28,7 @@ export class AccessibilityManager extends Disposable { private _liveRegion: HTMLElement; private _liveRegionLineCount: number = 0; - private _renderRowsDebouncer: TimeBasedDebouncer; + private _renderRowsDebouncer: IRenderDebouncer; private _screenDprMonitor: ScreenDprMonitor; private _topBoundaryFocusListener: (e: FocusEvent) => void; diff --git a/src/browser/RenderDebouncer.ts b/src/browser/RenderDebouncer.ts index 2a06fdd66..025210707 100644 --- a/src/browser/RenderDebouncer.ts +++ b/src/browser/RenderDebouncer.ts @@ -3,12 +3,12 @@ * @license MIT */ -import { IDisposable } from 'common/Types'; +import { IRenderDebouncer } from 'browser/Types'; /** * Debounces calls to render terminal rows using animation frames. */ -export class RenderDebouncer implements IDisposable { +export class RenderDebouncer implements IRenderDebouncer { private _rowStart: number | undefined; private _rowEnd: number | undefined; private _rowCount: number | undefined; diff --git a/src/browser/TimeBasedDebouncer.ts b/src/browser/TimeBasedDebouncer.ts index 843787d5f..e4aeb387d 100644 --- a/src/browser/TimeBasedDebouncer.ts +++ b/src/browser/TimeBasedDebouncer.ts @@ -5,12 +5,12 @@ const RENDER_DEBOUNCE_THRESHOLD_MS = 1000; // 1 Second -import { IDisposable } from 'common/Types'; +import { IRenderDebouncer } from 'browser/Types'; /** * Debounces calls to update screen readers to update at most once per second. */ -export class TimeBasedDebouncer implements IDisposable { +export class TimeBasedDebouncer implements IRenderDebouncer { private _rowStart: number | undefined; private _rowEnd: number | undefined; private _rowCount: number | undefined; diff --git a/src/browser/Types.d.ts b/src/browser/Types.d.ts index c268c7bf8..0d74b39fa 100644 --- a/src/browser/Types.d.ts +++ b/src/browser/Types.d.ts @@ -309,3 +309,7 @@ export interface ICharacterJoiner { id: number; handler: CharacterJoinerHandler; } + +export interface IRenderDebouncer extends IDisposable { + refresh(rowStart: number | undefined, rowEnd: number | undefined, rowCount: number): void; +} diff --git a/src/browser/services/RenderService.ts b/src/browser/services/RenderService.ts index fc2eb4354..332e71dae 100644 --- a/src/browser/services/RenderService.ts +++ b/src/browser/services/RenderService.ts @@ -9,7 +9,7 @@ import { EventEmitter, IEvent } from 'common/EventEmitter'; import { Disposable } from 'common/Lifecycle'; import { ScreenDprMonitor } from 'browser/ScreenDprMonitor'; import { addDisposableDomListener } from 'browser/Lifecycle'; -import { IColorSet } from 'browser/Types'; +import { IColorSet, IRenderDebouncer } from 'browser/Types'; import { IOptionsService, IBufferService } from 'common/services/Services'; import { ICharSizeService, IRenderService } from 'browser/services/Services'; @@ -22,7 +22,7 @@ interface ISelectionState { export class RenderService extends Disposable implements IRenderService { public serviceBrand: undefined; - private _renderDebouncer: RenderDebouncer; + private _renderDebouncer: IRenderDebouncer; private _screenDprMonitor: ScreenDprMonitor; private _isPaused: boolean = false; From 9f24cf7e72a729946e606105b48f12dd953fad5a Mon Sep 17 00:00:00 2001 From: Samuel Sampson Date: Tue, 17 Aug 2021 21:28:58 +0000 Subject: [PATCH 103/164] Cancel queued refreshes in TimeBasedDebouncer on dispose --- src/browser/TimeBasedDebouncer.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/browser/TimeBasedDebouncer.ts b/src/browser/TimeBasedDebouncer.ts index e4aeb387d..455621d7f 100644 --- a/src/browser/TimeBasedDebouncer.ts +++ b/src/browser/TimeBasedDebouncer.ts @@ -20,12 +20,18 @@ export class TimeBasedDebouncer implements IRenderDebouncer { // Whether a trailing refresh should be triggered due to a refresh request that was throttled private _additionalRefreshRequested = false; + private _refreshTimeoutID: number | undefined; + constructor( private _renderCallback: (start: number, end: number) => void ) { } - public dispose(): void {} + public dispose(): void { + if (this._refreshTimeoutID) { + clearTimeout(this._refreshTimeoutID); + } + } public refresh(rowStart: number | undefined, rowEnd: number | undefined, rowCount: number): void { this._rowCount = rowCount; @@ -49,7 +55,7 @@ export class TimeBasedDebouncer implements IRenderDebouncer { const waitPeriodBeforeTrailingRefresh = RENDER_DEBOUNCE_THRESHOLD_MS - elapsed; this._additionalRefreshRequested = true; - setTimeout(() => { + this._refreshTimeoutID = window.setTimeout(() => { this._lastRefreshMs = Date.now(); this._innerRefresh(); this._additionalRefreshRequested = false; From ae58302dfaba3ffa2a8db74f88e728e8c875db2f Mon Sep 17 00:00:00 2001 From: Samuel Sampson Date: Tue, 17 Aug 2021 21:36:47 +0000 Subject: [PATCH 104/164] Allow render debounce interval to be configured at construction time in TimeBasedDebouncer --- src/browser/TimeBasedDebouncer.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/browser/TimeBasedDebouncer.ts b/src/browser/TimeBasedDebouncer.ts index 455621d7f..584b33ce9 100644 --- a/src/browser/TimeBasedDebouncer.ts +++ b/src/browser/TimeBasedDebouncer.ts @@ -8,7 +8,7 @@ const RENDER_DEBOUNCE_THRESHOLD_MS = 1000; // 1 Second import { IRenderDebouncer } from 'browser/Types'; /** - * Debounces calls to update screen readers to update at most once per second. + * Debounces calls to update screen readers to update at most once configurable interval of time. */ export class TimeBasedDebouncer implements IRenderDebouncer { private _rowStart: number | undefined; @@ -23,7 +23,8 @@ export class TimeBasedDebouncer implements IRenderDebouncer { private _refreshTimeoutID: number | undefined; constructor( - private _renderCallback: (start: number, end: number) => void + private _renderCallback: (start: number, end: number) => void, + private readonly debounceThresholdMS = RENDER_DEBOUNCE_THRESHOLD_MS ) { } @@ -45,14 +46,14 @@ export class TimeBasedDebouncer implements IRenderDebouncer { // Only refresh if the time since last refresh is above a threshold, otherwise wait for // enough time to pass before refreshing again. const refreshRequestTime: number = Date.now(); - if (refreshRequestTime - this._lastRefreshMs >= RENDER_DEBOUNCE_THRESHOLD_MS) { + if (refreshRequestTime - this._lastRefreshMs >= this.debounceThresholdMS) { // Enough time has lapsed since the last refresh; refresh immediately this._lastRefreshMs = refreshRequestTime; this._innerRefresh(); } else if (!this._additionalRefreshRequested) { // This is the first additional request throttled; set up trailing refresh const elapsed = refreshRequestTime - this._lastRefreshMs; - const waitPeriodBeforeTrailingRefresh = RENDER_DEBOUNCE_THRESHOLD_MS - elapsed; + const waitPeriodBeforeTrailingRefresh = this.debounceThresholdMS - elapsed; this._additionalRefreshRequested = true; this._refreshTimeoutID = window.setTimeout(() => { From e778df672acd8098c8bfd0adae5600420fc65fa3 Mon Sep 17 00:00:00 2001 From: Samuel Sampson Date: Tue, 17 Aug 2021 22:20:04 +0000 Subject: [PATCH 105/164] Don't clear timeouts in TimeBasedDebouncer if they've already been executed. --- src/browser/TimeBasedDebouncer.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/browser/TimeBasedDebouncer.ts b/src/browser/TimeBasedDebouncer.ts index 584b33ce9..03e1a0c24 100644 --- a/src/browser/TimeBasedDebouncer.ts +++ b/src/browser/TimeBasedDebouncer.ts @@ -60,6 +60,7 @@ export class TimeBasedDebouncer implements IRenderDebouncer { this._lastRefreshMs = Date.now(); this._innerRefresh(); this._additionalRefreshRequested = false; + this._refreshTimeoutID = undefined; // No longer need to clear the timeout }, waitPeriodBeforeTrailingRefresh); } } From 42e0fcda29d2f202feb9b8ef6318eb1adb421d5a Mon Sep 17 00:00:00 2001 From: Samuel Sampson Date: Tue, 17 Aug 2021 22:26:14 +0000 Subject: [PATCH 106/164] Fix lint error due to private variable --- src/browser/TimeBasedDebouncer.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/browser/TimeBasedDebouncer.ts b/src/browser/TimeBasedDebouncer.ts index 03e1a0c24..707e25cbb 100644 --- a/src/browser/TimeBasedDebouncer.ts +++ b/src/browser/TimeBasedDebouncer.ts @@ -24,7 +24,7 @@ export class TimeBasedDebouncer implements IRenderDebouncer { constructor( private _renderCallback: (start: number, end: number) => void, - private readonly debounceThresholdMS = RENDER_DEBOUNCE_THRESHOLD_MS + private readonly _debounceThresholdMS = RENDER_DEBOUNCE_THRESHOLD_MS ) { } @@ -46,14 +46,14 @@ export class TimeBasedDebouncer implements IRenderDebouncer { // Only refresh if the time since last refresh is above a threshold, otherwise wait for // enough time to pass before refreshing again. const refreshRequestTime: number = Date.now(); - if (refreshRequestTime - this._lastRefreshMs >= this.debounceThresholdMS) { + if (refreshRequestTime - this._lastRefreshMs >= this._debounceThresholdMS) { // Enough time has lapsed since the last refresh; refresh immediately this._lastRefreshMs = refreshRequestTime; this._innerRefresh(); } else if (!this._additionalRefreshRequested) { // This is the first additional request throttled; set up trailing refresh const elapsed = refreshRequestTime - this._lastRefreshMs; - const waitPeriodBeforeTrailingRefresh = this.debounceThresholdMS - elapsed; + const waitPeriodBeforeTrailingRefresh = this._debounceThresholdMS - elapsed; this._additionalRefreshRequested = true; this._refreshTimeoutID = window.setTimeout(() => { From 9fb1ce11fb2708b89ea32c4940cb953fd15e9fc8 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 18 Aug 2021 06:44:13 -0700 Subject: [PATCH 107/164] Add setting, clean up drawing, fix true color --- src/browser/renderer/BaseRenderLayer.ts | 55 +++++------- src/browser/renderer/BoxAndBlockCharacters.ts | 90 ++++++++++++++++--- src/common/services/OptionsService.ts | 1 + src/common/services/Services.ts | 1 + typings/xterm-headless.d.ts | 8 ++ typings/xterm.d.ts | 8 ++ 6 files changed, 118 insertions(+), 45 deletions(-) diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 44b238402..e7116ed69 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -17,7 +17,7 @@ import { IBufferService, IOptionsService } from 'common/services/Services'; import { throwIfFalsy } from 'browser/renderer/RendererUtils'; import { channels, color, rgba } from 'browser/Color'; import { removeElementFromParent } from 'browser/Dom'; -import { boxCharacters, boxDrawingBoxes, drawBoxChar } from 'browser/renderer/BoxAndBlockCharacters'; +import { tryDrawCustomChar } from 'browser/renderer/BoxAndBlockCharacters'; export abstract class BaseRenderLayer implements IRenderLayer { private _canvas: HTMLCanvasElement; @@ -260,8 +260,15 @@ export abstract class BaseRenderLayer implements IRenderLayer { this._ctx.font = this._getFont(false, false); this._ctx.textBaseline = 'ideographic'; this._clipRow(y); - // TODO: fix - if (!this._drawBoxChar(cell, x, y)) { + + // Draw custom characters if applicable + let drawSuccess = false; + if (this._optionsService.options.customBlockAndBoxCharacters !== false) { + drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x, y, this._scaledCellWidth, this._scaledCellHeight, this._scaledCharLeft, this._scaledCharTop); + } + + // Draw the character + if (!drawSuccess) { this._ctx.fillText( cell.getChars(), x * this._scaledCellWidth + this._scaledCharLeft, @@ -377,46 +384,24 @@ export abstract class BaseRenderLayer implements IRenderLayer { if (cell.isDim()) { this._ctx.globalAlpha = DIM_OPACITY; } - if (!this._drawBoxChar(cell, x, y)) { - // Draw the character + + // Draw custom characters if applicable + let drawSuccess = false; + if (this._optionsService.options.customBlockAndBoxCharacters !== false) { + drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x, y, this._scaledCellWidth, this._scaledCellHeight, this._scaledCharLeft, this._scaledCharTop); + } + + // Draw the character + if (!drawSuccess) { this._ctx.fillText( cell.getChars(), x * this._scaledCellWidth + this._scaledCharLeft, y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight); } + this._ctx.restore(); } - private _drawBoxChar(cell: ICellData, x: number, y: number): boolean { - const char = cell.getChars(); - - const boxes = boxDrawingBoxes[char]; - if (boxes) { - this._ctx.strokeStyle = this._ctx.fillStyle; - const xOffset = x * this._scaledCellWidth + this._scaledCharLeft; - const yOffset = y * this._scaledCellHeight + this._scaledCharTop; - for (let i = 0; i < boxes.length; i++) { - const box = boxes[i]; - const xEighth = this._scaledCellWidth / 8; - const yEighth = this._scaledCellHeight / 8; - this._ctx.fillRect( - xOffset, - yOffset, - box.w * xEighth, - box.h * yEighth); - } - return true; - } - - const lineSegments = boxCharacters[char]; - if (!lineSegments) { - return false; - } - this._ctx.strokeStyle = this._ctx.fillStyle; - drawBoxChar(this._ctx, char, x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); - return true; - } - /** * Clips a row to ensure no pixels will be drawn outside the cells in the row. diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index ac37c761c..81cfaba86 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -1,5 +1,16 @@ +/** + * Copyright (c) 2021 The xterm.js authors. All rights reserved. + * @license MIT + */ -export const boxDrawingBoxes: { [index: string]: any } = { +interface IBlockVector { + x: number; + y: number; + w: number; + h: number; +} + +export const blockElementChars: { [index: string]: IBlockVector[] | undefined } = { '▀': [{ x: 0, y: 0, w: 8, h: 4 }], '█': [{ x: 0, y: 0, w: 8, h: 8 }], '▇': [{ x: 0, y: 1, w: 8, h: 7 }], @@ -125,7 +136,7 @@ const enum Style { } // This contains the definitions of all box drawing characters as SVG paths (ie. the svg d attribute) -export const boxCharacters: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } } = { +export const boxDrawingChars: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } | undefined } = { // Uniform normal and bold '─': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT }, '━': { [Style.BOLD]: Shapes.LEFT_TO_RIGHT }, @@ -247,7 +258,6 @@ export const boxCharacters: { [character: string]: { [fontWeight: number]: strin '╊': { [Style.NORMAL]: Shapes.MIDDLE_TO_LEFT, [Style.BOLD]: `${Shapes.TOP_TO_BOTTOM} ${Shapes.MIDDLE_TO_RIGHT}` }, // Dashed - // TODO: Spacing dashes evenly, use 1/2 padding on each edge so the line is continuous '╌': { [Style.NORMAL]: Shapes.TWO_DASHES_HORIZONTAL }, '╍': { [Style.BOLD]: Shapes.TWO_DASHES_HORIZONTAL }, '┄': { [Style.NORMAL]: Shapes.THREE_DASHES_HORIZONTAL }, @@ -268,18 +278,78 @@ export const boxCharacters: { [character: string]: { [fontWeight: number]: strin '╰': { [Style.NORMAL]: 'C.5,0,.5,.5,1,.5' } }; -export function drawBoxChar(ctx: CanvasRenderingContext2D, c: string, xOffset: number, yOffset: number, cellWidth: number, cellHeight: number): void { - const match: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } = boxCharacters[c]; - if (!match) { - return; +/** + * Try drawing a custom block element or box drawing character, returning whether it was + * successfully drawn. + */ +export function tryDrawCustomChar( + ctx: CanvasRenderingContext2D, + c: string, + x: number, + y: number, + scaledCellWidth: number, + scaledCellHeight: number, + scaledCharLeft: number, + scaledCharTop: number +): boolean { + const blockElementInstruction = blockElementChars[c]; + if (blockElementInstruction) { + drawBlockElementChar(ctx, blockElementInstruction, x, y, scaledCellWidth, scaledCellHeight, scaledCharLeft, scaledCharTop); + return true; } - for (const [fontWeight, instructions] of Object.entries(match)) { + + const boxDrawingInstruction = boxDrawingChars[c]; + if (boxDrawingInstruction) { + drawBoxDrawingChar(ctx, boxDrawingInstruction, x, y, scaledCellWidth, scaledCellHeight); + return true; + } + + return false; +} + +function drawBlockElementChar( + ctx: CanvasRenderingContext2D, + instruction: IBlockVector[], + x: number, + y: number, + scaledCellWidth: number, + scaledCellHeight: number, + scaledCharLeft: number, + scaledCharTop: number +): void { + const xOffset = x * scaledCellWidth + scaledCharLeft; + const yOffset = y * scaledCellHeight + scaledCharTop; + for (let i = 0; i < instruction.length; i++) { + const box = instruction[i]; + const xEighth = scaledCellWidth / 8; + const yEighth = scaledCellHeight / 8; + ctx.fillRect( + xOffset, + yOffset, + box.w * xEighth, + box.h * yEighth + ); + } +} + +function drawBoxDrawingChar( + ctx: CanvasRenderingContext2D, + charDefinition: { [fontWeight: number]: string | ((xp: number, yp: number) => string) }, + x: number, + y: number, + scaledCellWidth: number, + scaledCellHeight: number +): void { + const xOffset = x * scaledCellWidth; + const yOffset = y * scaledCellHeight; + ctx.strokeStyle = ctx.fillStyle; + for (const [fontWeight, instructions] of Object.entries(charDefinition)) { ctx.beginPath(); ctx.lineWidth = window.devicePixelRatio * Number.parseInt(fontWeight); let actualInstructions: string; if (typeof instructions === 'function') { const xp = .15; - const yp = .15 / cellHeight * cellWidth; + const yp = .15 / scaledCellHeight * scaledCellWidth; actualInstructions = instructions(xp, yp); } else { actualInstructions = instructions; @@ -295,7 +365,7 @@ export function drawBoxChar(ctx: CanvasRenderingContext2D, c: string, xOffset: n if (!args[0] || !args[1]) { continue; } - f(ctx, translateArgs(args, cellWidth, cellHeight, xOffset, yOffset)); + f(ctx, translateArgs(args, scaledCellWidth, scaledCellHeight, xOffset, yOffset)); } ctx.stroke(); ctx.closePath(); diff --git a/src/common/services/OptionsService.ts b/src/common/services/OptionsService.ts index b7a1c58e0..062166bc9 100644 --- a/src/common/services/OptionsService.ts +++ b/src/common/services/OptionsService.ts @@ -21,6 +21,7 @@ export const DEFAULT_OPTIONS: ITerminalOptions = Object.freeze({ cursorBlink: false, cursorStyle: 'block', cursorWidth: 1, + customBlockAndBoxCharacters: true, bellSound: DEFAULT_BELL_SOUND, bellStyle: 'none', drawBoldTextInBrightColors: true, diff --git a/src/common/services/Services.ts b/src/common/services/Services.ts index ce2973222..07615a413 100644 --- a/src/common/services/Services.ts +++ b/src/common/services/Services.ts @@ -244,6 +244,7 @@ export interface ITerminalOptions { cursorBlink: boolean; cursorStyle: 'block' | 'underline' | 'bar'; cursorWidth: number; + customBlockAndBoxCharacters: boolean; disableStdin: boolean; drawBoldTextInBrightColors: boolean; fastScrollModifier: 'alt' | 'ctrl' | 'shift' | undefined; diff --git a/typings/xterm-headless.d.ts b/typings/xterm-headless.d.ts index b6e1505b1..dc886aa1d 100644 --- a/typings/xterm-headless.d.ts +++ b/typings/xterm-headless.d.ts @@ -78,6 +78,14 @@ declare module 'xterm-headless' { */ cursorWidth?: number; + /** + * Whether to draw custom block element and box drawing characters instead of using the font. + * This should typically result in better rendering with continuous lines. Note that this + * doesn't work with the DOM renderer which renders all characters using the font. The default + * is true. + */ + customBlockAndBoxCharacters?: boolean; + /** * Whether input should be disabled. */ diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 3828b415a..f6fbe709d 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -90,6 +90,14 @@ declare module 'xterm' { */ cursorWidth?: number; + /** + * Whether to draw custom block element and box drawing characters instead of using the font. + * This should typically result in better rendering with continuous lines. Note that this + * doesn't work with the DOM renderer which renders all characters using the font. The default + * is true. + */ + customBlockAndBoxCharacters?: boolean; + /** * Whether input should be disabled. */ From 86a30dc689d20a776688404fdc88f3dc10145bdb Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 18 Aug 2021 06:45:40 -0700 Subject: [PATCH 108/164] Clean up usage of instruction/definition --- src/browser/renderer/BoxAndBlockCharacters.ts | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index 81cfaba86..e4d549fb9 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -10,7 +10,7 @@ interface IBlockVector { h: number; } -export const blockElementChars: { [index: string]: IBlockVector[] | undefined } = { +export const blockElementDefinitions: { [index: string]: IBlockVector[] | undefined } = { '▀': [{ x: 0, y: 0, w: 8, h: 4 }], '█': [{ x: 0, y: 0, w: 8, h: 8 }], '▇': [{ x: 0, y: 1, w: 8, h: 7 }], @@ -136,7 +136,7 @@ const enum Style { } // This contains the definitions of all box drawing characters as SVG paths (ie. the svg d attribute) -export const boxDrawingChars: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } | undefined } = { +export const boxDrawingDefinitions: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } | undefined } = { // Uniform normal and bold '─': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT }, '━': { [Style.BOLD]: Shapes.LEFT_TO_RIGHT }, @@ -292,15 +292,15 @@ export function tryDrawCustomChar( scaledCharLeft: number, scaledCharTop: number ): boolean { - const blockElementInstruction = blockElementChars[c]; - if (blockElementInstruction) { - drawBlockElementChar(ctx, blockElementInstruction, x, y, scaledCellWidth, scaledCellHeight, scaledCharLeft, scaledCharTop); + const blockElementDefinition = blockElementDefinitions[c]; + if (blockElementDefinition) { + drawBlockElementChar(ctx, blockElementDefinition, x, y, scaledCellWidth, scaledCellHeight, scaledCharLeft, scaledCharTop); return true; } - const boxDrawingInstruction = boxDrawingChars[c]; - if (boxDrawingInstruction) { - drawBoxDrawingChar(ctx, boxDrawingInstruction, x, y, scaledCellWidth, scaledCellHeight); + const boxDrawingDefinition = boxDrawingDefinitions[c]; + if (boxDrawingDefinition) { + drawBoxDrawingChar(ctx, boxDrawingDefinition, x, y, scaledCellWidth, scaledCellHeight); return true; } @@ -309,7 +309,7 @@ export function tryDrawCustomChar( function drawBlockElementChar( ctx: CanvasRenderingContext2D, - instruction: IBlockVector[], + charDefinition: IBlockVector[], x: number, y: number, scaledCellWidth: number, @@ -319,8 +319,8 @@ function drawBlockElementChar( ): void { const xOffset = x * scaledCellWidth + scaledCharLeft; const yOffset = y * scaledCellHeight + scaledCharTop; - for (let i = 0; i < instruction.length; i++) { - const box = instruction[i]; + for (let i = 0; i < charDefinition.length; i++) { + const box = charDefinition[i]; const xEighth = scaledCellWidth / 8; const yEighth = scaledCellHeight / 8; ctx.fillRect( From e5d66d63f5efedaedd152af9c6cd2fe1a7f8e1ae Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 18 Aug 2021 07:00:10 -0700 Subject: [PATCH 109/164] Fix offset of block elements --- src/browser/renderer/BoxAndBlockCharacters.ts | 53 +++++++++++++++++-- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index e4d549fb9..fd8976755 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -135,7 +135,10 @@ const enum Style { BOLD = 3 } -// This contains the definitions of all box drawing characters as SVG paths (ie. the svg d attribute) +/** + * This contains the definitions of all box drawing characters in the format of SVG paths (ie. the + * svg d attribute). + */ export const boxDrawingDefinitions: { [character: string]: { [fontWeight: number]: string | ((xp: number, yp: number) => string) } | undefined } = { // Uniform normal and bold '─': { [Style.NORMAL]: Shapes.LEFT_TO_RIGHT }, @@ -324,14 +327,54 @@ function drawBlockElementChar( const xEighth = scaledCellWidth / 8; const yEighth = scaledCellHeight / 8; ctx.fillRect( - xOffset, - yOffset, + xOffset + box.x * xEighth, + yOffset + box.y * yEighth, box.w * xEighth, box.h * yEighth ); } } +/** + * Draws the following box drawing characters by mapping a subset of SVG d attribute instructions to + * canvas draw calls. + * + * Box styles: ┎┰┒┍┯┑╓╥╖╒╤╕ ┏┳┓┌┲┓┌┬┐┏┱┐ + * ┌─┬─┐ ┏━┳━┓ ╔═╦═╗ ┠╂┨┝┿┥╟╫╢╞╪╡ ┡╇┩├╊┫┢╈┪┣╉┤ + * │ │ │ ┃ ┃ ┃ ║ ║ ║ ┖┸┚┕┷┙╙╨╜╘╧╛ └┴┘└┺┛┗┻┛┗┹┘ + * ├─┼─┤ ┣━╋━┫ ╠═╬═╣ ┏┱┐┌┲┓┌┬┐┌┬┐ ┏┳┓┌┮┓┌┬┐┏┭┐ + * │ │ │ ┃ ┃ ┃ ║ ║ ║ ┡╃┤├╄┩├╆┪┢╅┤ ┞╀┦├┾┫┟╁┧┣┽┤ + * └─┴─┘ ┗━┻━┛ ╚═╩═╝ └┴┘└┴┘└┺┛┗┹┘ └┴┘└┶┛┗┻┛┗┵┘ + * + * Other: + * ╭─╮ ╲ ╱ ╷╻╎╏┆┇┊┋ ╺╾╴ ╌╌╌ ┄┄┄ ┈┈┈ + * │ │ ╳ ╽╿╎╏┆┇┊┋ ╶╼╸ ╍╍╍ ┅┅┅ ┉┉┉ + * ╰─╯ ╱ ╲ ╹╵╎╏┆┇┊┋ + * + * All box drawing characters: + * ─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏ + * ┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟ + * ┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯ + * ┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿ + * ╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╌ ╍ ╎ ╏ + * ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ + * ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯ + * ╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿ + * + * --- + * + * Box drawing alignment tests: █ + * ▉ + * ╔══╦══╗ ┌──┬──┐ ╭──┬──╮ ╭──┬──╮ ┏━━┳━━┓ ┎┒┏┑ ╷ ╻ ┏┯┓ ┌┰┐ ▊ ╱╲╱╲╳╳╳ + * ║┌─╨─┐║ │╔═╧═╗│ │╒═╪═╕│ │╓─╁─╖│ ┃┌─╂─┐┃ ┗╃╄┙ ╶┼╴╺╋╸┠┼┨ ┝╋┥ ▋ ╲╱╲╱╳╳╳ + * ║│╲ ╱│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╿ │┃ ┍╅╆┓ ╵ ╹ ┗┷┛ └┸┘ ▌ ╱╲╱╲╳╳╳ + * ╠╡ ╳ ╞╣ ├╢ ╟┤ ├┼─┼─┼┤ ├╫─╂─╫┤ ┣┿╾┼╼┿┫ ┕┛┖┚ ┌┄┄┐ ╎ ┏┅┅┓ ┋ ▍ ╲╱╲╱╳╳╳ + * ║│╱ ╲│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╽ │┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▎ + * ║└─╥─┘║ │╚═╤═╝│ │╘═╪═╛│ │╙─╀─╜│ ┃└─╂─┘┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▏ + * ╚══╩══╝ └──┴──┘ ╰──┴──╯ ╰──┴──╯ ┗━━┻━━┛ └╌╌┘ ╎ ┗╍╍┛ ┋ ▁▂▃▄▅▆▇█ + * + * Source: https://www.w3.org/2001/06/utf-8-test/UTF-8-demo.html + */ function drawBoxDrawingChar( ctx: CanvasRenderingContext2D, charDefinition: { [fontWeight: number]: string | ((xp: number, yp: number) => string) }, @@ -356,7 +399,7 @@ function drawBoxDrawingChar( } for (const instruction of actualInstructions.split(' ')) { const type = instruction[0]; - const f = instructionMap[type]; + const f = svgToCanvasInstructionMap[type]; if (!f) { console.error(`Could not find drawing instructions for "${type}"`); continue; @@ -376,7 +419,7 @@ function clamp(value: number, max: number, min: number = 0): number { return Math.max(Math.min(value, max), min); } -const instructionMap: { [index: string]: any } = { +const svgToCanvasInstructionMap: { [index: string]: any } = { 'C': (ctx: CanvasRenderingContext2D, args: number[]) => ctx.bezierCurveTo(args[0], args[1], args[2], args[3], args[4], args[5]), 'L': (ctx: CanvasRenderingContext2D, args: number[]) => ctx.lineTo(args[0], args[1]), 'M': (ctx: CanvasRenderingContext2D, args: number[]) => ctx.moveTo(args[0], args[1]) From 0aaa20f87338442036cb80d3a127362d37a00684 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 18 Aug 2021 07:31:35 -0700 Subject: [PATCH 110/164] Start of webgl integration --- addons/xterm-addon-webgl/src/WebglRenderer.ts | 2 +- .../src/atlas/CharAtlasCache.ts | 4 +++- .../src/atlas/CharAtlasUtils.ts | 5 +++- addons/xterm-addon-webgl/src/atlas/Types.d.ts | 3 +++ .../src/atlas/WebglCharAtlas.ts | 11 ++++++++- .../src/renderLayer/BaseRenderLayer.ts | 2 +- src/browser/Terminal.ts | 1 + src/browser/renderer/BaseRenderLayer.ts | 4 ++-- src/browser/renderer/BoxAndBlockCharacters.ts | 23 +++++++++---------- 9 files changed, 36 insertions(+), 19 deletions(-) diff --git a/addons/xterm-addon-webgl/src/WebglRenderer.ts b/addons/xterm-addon-webgl/src/WebglRenderer.ts index 29e97d6dc..75b6230c1 100644 --- a/addons/xterm-addon-webgl/src/WebglRenderer.ts +++ b/addons/xterm-addon-webgl/src/WebglRenderer.ts @@ -230,7 +230,7 @@ export class WebglRenderer extends Disposable implements IRenderer { return; } - const atlas = acquireCharAtlas(this._terminal, this._colors, this.dimensions.scaledCharWidth, this.dimensions.scaledCharHeight); + const atlas = acquireCharAtlas(this._terminal, this._colors, this.dimensions.scaledCellWidth, this.dimensions.scaledCellHeight, this.dimensions.scaledCharWidth, this.dimensions.scaledCharHeight); if (!('getRasterizedGlyph' in atlas)) { throw new Error('The webgl renderer only works with the webgl char atlas'); } diff --git a/addons/xterm-addon-webgl/src/atlas/CharAtlasCache.ts b/addons/xterm-addon-webgl/src/atlas/CharAtlasCache.ts index 5046006f2..41114de0f 100644 --- a/addons/xterm-addon-webgl/src/atlas/CharAtlasCache.ts +++ b/addons/xterm-addon-webgl/src/atlas/CharAtlasCache.ts @@ -28,10 +28,12 @@ const charAtlasCache: ICharAtlasCacheEntry[] = []; export function acquireCharAtlas( terminal: Terminal, colors: IColorSet, + scaledCellWidth: number, + scaledCellHeight: number, scaledCharWidth: number, scaledCharHeight: number ): WebglCharAtlas { - const newConfig = generateConfig(scaledCharWidth, scaledCharHeight, terminal, colors); + const newConfig = generateConfig(scaledCellWidth, scaledCellHeight, scaledCharWidth, scaledCharHeight, terminal, colors); // Check to see if the terminal already owns this config for (let i = 0; i < charAtlasCache.length; i++) { diff --git a/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts b/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts index 5496a500b..e91c5fd16 100644 --- a/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts +++ b/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts @@ -13,7 +13,7 @@ const NULL_COLOR: IColor = { rgba: 0 }; -export function generateConfig(scaledCharWidth: number, scaledCharHeight: number, terminal: Terminal, colors: IColorSet): ICharAtlasConfig { +export function generateConfig(scaledCellWidth: number, scaledCellHeight: number, scaledCharWidth: number, scaledCharHeight: number, terminal: Terminal, colors: IColorSet): ICharAtlasConfig { // null out some fields that don't matter const clonedColors: IColorSet = { foreground: colors.foreground, @@ -28,7 +28,10 @@ export function generateConfig(scaledCharWidth: number, scaledCharHeight: number contrastCache: colors.contrastCache }; return { + customBlockAndBoxCharacters: terminal.getOption('customBlockAndBoxCharacters'), devicePixelRatio: window.devicePixelRatio, + scaledCellWidth, + scaledCellHeight, scaledCharWidth, scaledCharHeight, fontFamily: terminal.getOption('fontFamily'), diff --git a/addons/xterm-addon-webgl/src/atlas/Types.d.ts b/addons/xterm-addon-webgl/src/atlas/Types.d.ts index cd73393ce..373843060 100644 --- a/addons/xterm-addon-webgl/src/atlas/Types.d.ts +++ b/addons/xterm-addon-webgl/src/atlas/Types.d.ts @@ -17,11 +17,14 @@ export interface IGlyphIdentifier { } export interface ICharAtlasConfig { + customBlockAndBoxCharacters: boolean; devicePixelRatio: number; fontSize: number; fontFamily: string; fontWeight: FontWeight; fontWeightBold: FontWeight; + scaledCellWidth: number; + scaledCellHeight: number; scaledCharWidth: number; scaledCharHeight: number; allowTransparency: boolean; diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 5f729e282..8fd43e1e8 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -12,6 +12,7 @@ import { IColor } from 'browser/Types'; import { IDisposable } from 'xterm'; import { AttributeData } from 'common/buffer/AttributeData'; import { channels, rgba } from 'browser/Color'; +import { tryDrawCustomChar } from 'browser/renderer/BoxAndBlockCharacters'; // In practice we're probably never going to exhaust a texture this large. For debugging purposes, // however, it can be useful to set this to a really tiny value, to verify that LRU eviction works. @@ -390,8 +391,16 @@ export class WebglCharAtlas implements IDisposable { // For powerline glyphs left/top padding is excluded (https://github.com/microsoft/vscode/issues/120129) const padding = isPowerlineGlyph ? 0 : TMP_CANVAS_GLYPH_PADDING; + // Draw custom characters if applicable + let drawSuccess = false; + if (this._config.customBlockAndBoxCharacters !== false) { + drawSuccess = tryDrawCustomChar(this._tmpCtx, chars, TMP_CANVAS_GLYPH_PADDING, TMP_CANVAS_GLYPH_PADDING, this._config.scaledCellWidth, this._config.scaledCellHeight, this._config.scaledCharWidth, this._config.scaledCharHeight); + } + // Draw the character - this._tmpCtx.fillText(chars, padding, padding + this._config.scaledCharHeight); + if (!drawSuccess) { + this._tmpCtx.fillText(chars, padding, padding + this._config.scaledCharHeight); + } // Draw underline and strikethrough if (underline || strikethrough) { diff --git a/addons/xterm-addon-webgl/src/renderLayer/BaseRenderLayer.ts b/addons/xterm-addon-webgl/src/renderLayer/BaseRenderLayer.ts index cc210fd32..532836eef 100644 --- a/addons/xterm-addon-webgl/src/renderLayer/BaseRenderLayer.ts +++ b/addons/xterm-addon-webgl/src/renderLayer/BaseRenderLayer.ts @@ -92,7 +92,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { if (this._scaledCharWidth <= 0 && this._scaledCharHeight <= 0) { return; } - this._charAtlas = acquireCharAtlas(terminal, colorSet, this._scaledCharWidth, this._scaledCharHeight); + this._charAtlas = acquireCharAtlas(terminal, colorSet, this._scaledCellWidth, this._scaledCellHeight, this._scaledCharWidth, this._scaledCharHeight); this._charAtlas.warmUp(); } diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index e702e61ed..3ab343da5 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -224,6 +224,7 @@ export class Terminal extends CoreTerminal implements ITerminal { // The DOM renderer needs a row refresh to update the cursor styles this.refresh(this.buffer.y, this.buffer.y); break; + case 'customBlockAndBoxCharacters': case 'drawBoldTextInBrightColors': case 'letterSpacing': case 'lineHeight': diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index e7116ed69..afa12bb2c 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -264,7 +264,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { // Draw custom characters if applicable let drawSuccess = false; if (this._optionsService.options.customBlockAndBoxCharacters !== false) { - drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x, y, this._scaledCellWidth, this._scaledCellHeight, this._scaledCharLeft, this._scaledCharTop); + drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight, this._scaledCharLeft, this._scaledCharTop); } // Draw the character @@ -388,7 +388,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { // Draw custom characters if applicable let drawSuccess = false; if (this._optionsService.options.customBlockAndBoxCharacters !== false) { - drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x, y, this._scaledCellWidth, this._scaledCellHeight, this._scaledCharLeft, this._scaledCharTop); + drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight, this._scaledCharLeft, this._scaledCharTop); } // Draw the character diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index fd8976755..b38199ad9 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -288,8 +288,8 @@ export const boxDrawingDefinitions: { [character: string]: { [fontWeight: number export function tryDrawCustomChar( ctx: CanvasRenderingContext2D, c: string, - x: number, - y: number, + xOffset: number, + yOffset: number, scaledCellWidth: number, scaledCellHeight: number, scaledCharLeft: number, @@ -297,13 +297,13 @@ export function tryDrawCustomChar( ): boolean { const blockElementDefinition = blockElementDefinitions[c]; if (blockElementDefinition) { - drawBlockElementChar(ctx, blockElementDefinition, x, y, scaledCellWidth, scaledCellHeight, scaledCharLeft, scaledCharTop); + drawBlockElementChar(ctx, blockElementDefinition, xOffset, yOffset, scaledCellWidth, scaledCellHeight, scaledCharLeft, scaledCharTop); return true; } const boxDrawingDefinition = boxDrawingDefinitions[c]; if (boxDrawingDefinition) { - drawBoxDrawingChar(ctx, boxDrawingDefinition, x, y, scaledCellWidth, scaledCellHeight); + drawBoxDrawingChar(ctx, boxDrawingDefinition, xOffset, yOffset, scaledCellWidth, scaledCellHeight); return true; } @@ -313,15 +313,16 @@ export function tryDrawCustomChar( function drawBlockElementChar( ctx: CanvasRenderingContext2D, charDefinition: IBlockVector[], - x: number, - y: number, + xOffset: number, + yOffset: number, scaledCellWidth: number, scaledCellHeight: number, scaledCharLeft: number, scaledCharTop: number ): void { - const xOffset = x * scaledCellWidth + scaledCharLeft; - const yOffset = y * scaledCellHeight + scaledCharTop; + // TODO: Scale to cell not char? + xOffset += scaledCharLeft; + yOffset += scaledCharTop; for (let i = 0; i < charDefinition.length; i++) { const box = charDefinition[i]; const xEighth = scaledCellWidth / 8; @@ -378,13 +379,11 @@ function drawBlockElementChar( function drawBoxDrawingChar( ctx: CanvasRenderingContext2D, charDefinition: { [fontWeight: number]: string | ((xp: number, yp: number) => string) }, - x: number, - y: number, + xOffset: number, + yOffset: number, scaledCellWidth: number, scaledCellHeight: number ): void { - const xOffset = x * scaledCellWidth; - const yOffset = y * scaledCellHeight; ctx.strokeStyle = ctx.fillStyle; for (const [fontWeight, instructions] of Object.entries(charDefinition)) { ctx.beginPath(); From fe7f28a7a0685f9ba83b5fe856bc241cb6207d32 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 18 Aug 2021 07:38:02 -0700 Subject: [PATCH 111/164] Fix block elements on webgl, scale block elements to cell --- .../xterm-addon-webgl/src/atlas/WebglCharAtlas.ts | 2 +- src/browser/renderer/BaseRenderLayer.ts | 4 ++-- src/browser/renderer/BoxAndBlockCharacters.ts | 13 +++---------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 8fd43e1e8..3b40659ee 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -394,7 +394,7 @@ export class WebglCharAtlas implements IDisposable { // Draw custom characters if applicable let drawSuccess = false; if (this._config.customBlockAndBoxCharacters !== false) { - drawSuccess = tryDrawCustomChar(this._tmpCtx, chars, TMP_CANVAS_GLYPH_PADDING, TMP_CANVAS_GLYPH_PADDING, this._config.scaledCellWidth, this._config.scaledCellHeight, this._config.scaledCharWidth, this._config.scaledCharHeight); + drawSuccess = tryDrawCustomChar(this._tmpCtx, chars, TMP_CANVAS_GLYPH_PADDING, TMP_CANVAS_GLYPH_PADDING, this._config.scaledCellWidth, this._config.scaledCellHeight); } // Draw the character diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index afa12bb2c..b994a8dfe 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -264,7 +264,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { // Draw custom characters if applicable let drawSuccess = false; if (this._optionsService.options.customBlockAndBoxCharacters !== false) { - drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight, this._scaledCharLeft, this._scaledCharTop); + drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); } // Draw the character @@ -388,7 +388,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { // Draw custom characters if applicable let drawSuccess = false; if (this._optionsService.options.customBlockAndBoxCharacters !== false) { - drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight, this._scaledCharLeft, this._scaledCharTop); + drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); } // Draw the character diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/BoxAndBlockCharacters.ts index b38199ad9..7d9a32bf3 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/BoxAndBlockCharacters.ts @@ -291,13 +291,11 @@ export function tryDrawCustomChar( xOffset: number, yOffset: number, scaledCellWidth: number, - scaledCellHeight: number, - scaledCharLeft: number, - scaledCharTop: number + scaledCellHeight: number ): boolean { const blockElementDefinition = blockElementDefinitions[c]; if (blockElementDefinition) { - drawBlockElementChar(ctx, blockElementDefinition, xOffset, yOffset, scaledCellWidth, scaledCellHeight, scaledCharLeft, scaledCharTop); + drawBlockElementChar(ctx, blockElementDefinition, xOffset, yOffset, scaledCellWidth, scaledCellHeight); return true; } @@ -316,13 +314,8 @@ function drawBlockElementChar( xOffset: number, yOffset: number, scaledCellWidth: number, - scaledCellHeight: number, - scaledCharLeft: number, - scaledCharTop: number + scaledCellHeight: number ): void { - // TODO: Scale to cell not char? - xOffset += scaledCharLeft; - yOffset += scaledCharTop; for (let i = 0; i < charDefinition.length; i++) { const box = charDefinition[i]; const xEighth = scaledCellWidth / 8; From da0928102b72e7c28d3513033b08524b76b48bb8 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 18 Aug 2021 08:19:23 -0700 Subject: [PATCH 112/164] Support shade char with patterns --- .../src/atlas/WebglCharAtlas.ts | 2 +- src/browser/renderer/BaseRenderLayer.ts | 2 +- ...xAndBlockCharacters.ts => CustomGlyphs.ts} | 88 +++++++++++++++++++ 3 files changed, 90 insertions(+), 2 deletions(-) rename src/browser/renderer/{BoxAndBlockCharacters.ts => CustomGlyphs.ts} (90%) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 3b40659ee..e1f695557 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -12,7 +12,7 @@ import { IColor } from 'browser/Types'; import { IDisposable } from 'xterm'; import { AttributeData } from 'common/buffer/AttributeData'; import { channels, rgba } from 'browser/Color'; -import { tryDrawCustomChar } from 'browser/renderer/BoxAndBlockCharacters'; +import { tryDrawCustomChar } from 'browser/renderer/CustomGlyphs'; // In practice we're probably never going to exhaust a texture this large. For debugging purposes, // however, it can be useful to set this to a really tiny value, to verify that LRU eviction works. diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index b994a8dfe..117213eb3 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -17,7 +17,7 @@ import { IBufferService, IOptionsService } from 'common/services/Services'; import { throwIfFalsy } from 'browser/renderer/RendererUtils'; import { channels, color, rgba } from 'browser/Color'; import { removeElementFromParent } from 'browser/Dom'; -import { tryDrawCustomChar } from 'browser/renderer/BoxAndBlockCharacters'; +import { tryDrawCustomChar } from 'browser/renderer/CustomGlyphs'; export abstract class BaseRenderLayer implements IRenderLayer { private _canvas: HTMLCanvasElement; diff --git a/src/browser/renderer/BoxAndBlockCharacters.ts b/src/browser/renderer/CustomGlyphs.ts similarity index 90% rename from src/browser/renderer/BoxAndBlockCharacters.ts rename to src/browser/renderer/CustomGlyphs.ts index 7d9a32bf3..55dafc6b4 100644 --- a/src/browser/renderer/BoxAndBlockCharacters.ts +++ b/src/browser/renderer/CustomGlyphs.ts @@ -3,6 +3,8 @@ * @license MIT */ +import { throwIfFalsy } from 'browser/renderer/RendererUtils'; + interface IBlockVector { x: number; y: number; @@ -101,6 +103,33 @@ export const blockElementDefinitions: { [index: string]: IBlockVector[] | undefi '\u{1FB97}': [{ x: 0, y: 2, w: 8, h: 2 }, { x: 0, y: 6, w: 8, h: 2 }] }; +type PatternDefinition = number[][]; + +/** + * Defines the repeating pattern used by special characters, the pattern is made up of a 2d array of + * pixel values to be filled (1) or not filled (0). + */ +const patternCharacterDefinitions: { [key: string]: PatternDefinition | undefined } = { + '░': [ + [1, 0, 0, 0], + [0, 0, 0, 0], + [0, 0, 1, 0], + [0, 0, 0, 0] + ], + '▒': [ + [1, 0], + [0, 0], + [0, 1], + [0, 0] + ], + '▓': [ + [0, 1], + [1, 1], + [1, 0], + [1, 1] + ] +}; + const enum Shapes { /** │ */ TOP_TO_BOTTOM = 'M.5,0 L.5,1', /** ─ */ LEFT_TO_RIGHT = 'M0,.5 L1,.5', @@ -299,6 +328,13 @@ export function tryDrawCustomChar( return true; } + const patternDefinition = patternCharacterDefinitions[c]; + if (patternDefinition) { + console.log('draw pattern', c); + drawPatternChar(ctx, patternDefinition, xOffset, yOffset, scaledCellWidth, scaledCellHeight); + return true; + } + const boxDrawingDefinition = boxDrawingDefinitions[c]; if (boxDrawingDefinition) { drawBoxDrawingChar(ctx, boxDrawingDefinition, xOffset, yOffset, scaledCellWidth, scaledCellHeight); @@ -329,6 +365,58 @@ function drawBlockElementChar( } } +const cachedPatterns: Map> = new Map(); + +function drawPatternChar( + ctx: CanvasRenderingContext2D, + charDefinition: number[][], + xOffset: number, + yOffset: number, + scaledCellWidth: number, + scaledCellHeight: number +): void { + let patternSet = cachedPatterns.get(charDefinition); + if (!patternSet) { + patternSet = new Map(); + cachedPatterns.set(charDefinition, patternSet); + } + // TODO: Unsafe? + const fillStyle = ctx.fillStyle as string; + let pattern = patternSet.get(fillStyle); + if (!pattern) { + const width = charDefinition[0].length; + const height = charDefinition.length; + const tmpCanvas = document.createElement('canvas'); + tmpCanvas.width = width; + tmpCanvas.height = height; + const tmpCtx = throwIfFalsy(tmpCanvas.getContext('2d')); + const imageData = new ImageData(width, height); + // TODO: This is a little unsafe, fillStyle could be rgb/rgba format + const r = parseInt(fillStyle.substr(1, 2), 16); + const g = parseInt(fillStyle.substr(3, 2), 16); + const b = parseInt(fillStyle.substr(5, 2), 16); + const a = fillStyle.length > 7 && parseInt(fillStyle.substr(7, 2), 16) || undefined; + for (let y = 0; y < height; y++) { + for (let x = 0; x < width; x++) { + imageData.data[(y * width + x) * 4 ] = r; + imageData.data[(y * width + x) * 4 + 1] = g; + imageData.data[(y * width + x) * 4 + 2] = b; + imageData.data[(y * width + x) * 4 + 3] = charDefinition[y][x] * (a ?? 255); + } + } + console.log('put', imageData); + tmpCtx.putImageData(imageData, 0, 0); + // TODO: This will break for different colored patterns + // TODO: This could happen multiple times + pattern = throwIfFalsy(ctx.createPattern(tmpCanvas, null)); + patternSet.set(fillStyle, pattern); + } + + console.log('fill style', pattern); + ctx.fillStyle = pattern; + ctx.fillRect(xOffset, yOffset, scaledCellWidth, scaledCellHeight); +} + /** * Draws the following box drawing characters by mapping a subset of SVG d attribute instructions to * canvas draw calls. From 011026a8d15fac5546d10c2fbe033516b7a09492 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 18 Aug 2021 08:29:07 -0700 Subject: [PATCH 113/164] Get webgl glyphs scaling to cell size, invalidate on option change --- addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts | 5 +++++ addons/xterm-addon-webgl/src/atlas/Types.d.ts | 2 ++ addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts | 6 +++--- src/browser/renderer/CustomGlyphs.ts | 5 ----- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts b/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts index e91c5fd16..6a4783383 100644 --- a/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts +++ b/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts @@ -30,6 +30,8 @@ export function generateConfig(scaledCellWidth: number, scaledCellHeight: number return { customBlockAndBoxCharacters: terminal.getOption('customBlockAndBoxCharacters'), devicePixelRatio: window.devicePixelRatio, + letterSpacing: terminal.getOption('letterSpacing'), + lineHeight: terminal.getOption('lineHeight'), scaledCellWidth, scaledCellHeight, scaledCharWidth, @@ -52,6 +54,9 @@ export function configEquals(a: ICharAtlasConfig, b: ICharAtlasConfig): boolean } } return a.devicePixelRatio === b.devicePixelRatio && + a.customBlockAndBoxCharacters === b.customBlockAndBoxCharacters && + a.lineHeight === b.lineHeight && + a.letterSpacing === b.letterSpacing && a.fontFamily === b.fontFamily && a.fontSize === b.fontSize && a.fontWeight === b.fontWeight && diff --git a/addons/xterm-addon-webgl/src/atlas/Types.d.ts b/addons/xterm-addon-webgl/src/atlas/Types.d.ts index 373843060..acbe3c71b 100644 --- a/addons/xterm-addon-webgl/src/atlas/Types.d.ts +++ b/addons/xterm-addon-webgl/src/atlas/Types.d.ts @@ -19,6 +19,8 @@ export interface IGlyphIdentifier { export interface ICharAtlasConfig { customBlockAndBoxCharacters: boolean; devicePixelRatio: number; + letterSpacing: number; + lineHeight: number; fontSize: number; fontFamily: string; fontWeight: FontWeight; diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index e1f695557..6da705225 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -84,8 +84,8 @@ export class WebglCharAtlas implements IDisposable { this._cacheCtx = throwIfFalsy(this.cacheCanvas.getContext('2d', { alpha: true })); this._tmpCanvas = document.createElement('canvas'); - this._tmpCanvas.width = this._config.scaledCharWidth * 4 + TMP_CANVAS_GLYPH_PADDING * 2; - this._tmpCanvas.height = this._config.scaledCharHeight + TMP_CANVAS_GLYPH_PADDING * 2; + this._tmpCanvas.width = this._config.scaledCellWidth * 4 + TMP_CANVAS_GLYPH_PADDING * 2; + this._tmpCanvas.height = this._config.scaledCellHeight + TMP_CANVAS_GLYPH_PADDING * 2; this._tmpCtx = throwIfFalsy(this._tmpCanvas.getContext('2d', { alpha: this._config.allowTransparency })); } @@ -321,7 +321,7 @@ export class WebglCharAtlas implements IDisposable { // Allow 1 cell width per character, with a minimum of 2 (CJK), plus some padding. This is used // to draw the glyph to the canvas as well as to restrict the bounding box search to ensure // giant ligatures (eg. =====>) don't impact overall performance. - const allowedWidth = this._config.scaledCharWidth * Math.max(chars.length, 2) + TMP_CANVAS_GLYPH_PADDING * 2; + let allowedWidth = this._config.scaledCharWidth * Math.max(chars.length, 2) + TMP_CANVAS_GLYPH_PADDING * 2; if (this._tmpCanvas.width < allowedWidth) { this._tmpCanvas.width = allowedWidth; } diff --git a/src/browser/renderer/CustomGlyphs.ts b/src/browser/renderer/CustomGlyphs.ts index 55dafc6b4..7457441b0 100644 --- a/src/browser/renderer/CustomGlyphs.ts +++ b/src/browser/renderer/CustomGlyphs.ts @@ -404,15 +404,10 @@ function drawPatternChar( imageData.data[(y * width + x) * 4 + 3] = charDefinition[y][x] * (a ?? 255); } } - console.log('put', imageData); tmpCtx.putImageData(imageData, 0, 0); - // TODO: This will break for different colored patterns - // TODO: This could happen multiple times pattern = throwIfFalsy(ctx.createPattern(tmpCanvas, null)); patternSet.set(fillStyle, pattern); } - - console.log('fill style', pattern); ctx.fillStyle = pattern; ctx.fillRect(xOffset, yOffset, scaledCellWidth, scaledCellHeight); } From 54ce0172b416d8bfe53a8fc8e55fddd487488d51 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 18 Aug 2021 09:48:27 -0700 Subject: [PATCH 114/164] Add test custom glyph button to demo --- .../src/atlas/WebglCharAtlas.ts | 2 +- .../test/WebglRenderer.api.ts | 55 +++++++++- demo/client.ts | 100 +++++++++++------- demo/index.html | 1 + src/browser/renderer/CustomGlyphs.ts | 1 - 5 files changed, 118 insertions(+), 41 deletions(-) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 6da705225..557e23ef2 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -321,7 +321,7 @@ export class WebglCharAtlas implements IDisposable { // Allow 1 cell width per character, with a minimum of 2 (CJK), plus some padding. This is used // to draw the glyph to the canvas as well as to restrict the bounding box search to ensure // giant ligatures (eg. =====>) don't impact overall performance. - let allowedWidth = this._config.scaledCharWidth * Math.max(chars.length, 2) + TMP_CANVAS_GLYPH_PADDING * 2; + const allowedWidth = this._config.scaledCharWidth * Math.max(chars.length, 2) + TMP_CANVAS_GLYPH_PADDING * 2; if (this._tmpCanvas.width < allowedWidth) { this._tmpCanvas.width = allowedWidth; } diff --git a/addons/xterm-addon-webgl/test/WebglRenderer.api.ts b/addons/xterm-addon-webgl/test/WebglRenderer.api.ts index 1722e5705..b666ceb41 100644 --- a/addons/xterm-addon-webgl/test/WebglRenderer.api.ts +++ b/addons/xterm-addon-webgl/test/WebglRenderer.api.ts @@ -6,7 +6,7 @@ import { ITerminalOptions } from '../../../src/common/Types'; import { ITheme } from 'xterm'; import { assert } from 'chai'; -import { openTerminal, pollFor, writeSync, getBrowserType } from '../../../out-test/api/TestUtils'; +import { openTerminal, pollFor, writeSync, getBrowserType, timeout } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; const APP = 'http://127.0.0.1:3001/test'; @@ -830,6 +830,45 @@ describe('WebGL Renderer Integration Tests', async () => { }); }); + describe.only('custom glyphs', () => { + if (areTestsEnabled) { + before(async () => setupBrowser()); + after(async () => browser.close()); + beforeEach(async () => page.evaluate(`window.term.reset()`)); + } + + itWebgl('should draw normal weight characters pixel perfect', async () => { + const theme: ITheme = { + background: '#000000', + foreground: '#ffffff' + }; + await page.evaluate(` + window.term.setOption('theme', ${JSON.stringify(theme)}); + window.term.setOption('fontSize', 12); + window.term.setOption('minimumContrastRatio', 1); + `); + await writeSync(page, + 'Box drawing alignment tests: █\\n\\r' + + ' ▉\\n\\r' + + ' ╔══╦══╗ ┌──┬──┐ ╭──┬──╮ ╭──┬──╮ ┏━━┳━━┓ ┎┒┏┑ ╷ ╻ ┏┯┓ ┌┰┐ ▊ ╱╲╱╲╳╳╳\\n\\r' + + ' ║┌─╨─┐║ │╔═╧═╗│ │╒═╪═╕│ │╓─╁─╖│ ┃┌─╂─┐┃ ┗╃╄┙ ╶┼╴╺╋╸┠┼┨ ┝╋┥ ▋ ╲╱╲╱╳╳╳\\n\\r' + + ' ║│╲ ╱│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╿ │┃ ┍╅╆┓ ╵ ╹ ┗┷┛ └┸┘ ▌ ╱╲╱╲╳╳╳\\n\\r' + + ' ╠╡ ╳ ╞╣ ├╢ ╟┤ ├┼─┼─┼┤ ├╫─╂─╫┤ ┣┿╾┼╼┿┫ ┕┛┖┚ ┌┄┄┐ ╎ ┏┅┅┓ ┋ ▍ ╲╱╲╱╳╳╳\\n\\r' + + ' ║│╱ ╲│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╽ │┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▎\\n\\r' + + ' ║└─╥─┘║ │╚═╤═╝│ │╘═╪═╛│ │╙─╀─╜│ ┃└─╂─┘┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▏\\n\\r' + + ' ╚══╩══╝ └──┴──┘ ╰──┴──╯ ╰──┴──╯ ┗━━┻━━┛ └╌╌┘ ╎ ┗╍╍┛ ┋ ▁▂▃▄▅▆▇█' + ); + // Validate before minimumContrastRatio is applied + await pollFor(page, () => getCellColor(1, 1), [0x2e, 0x34, 0x36, 255]); + const pixels = await getCellPixels(1, 1); + for (let y = 0; y < pixels.length / 20; y++) { + console.log(`pixels ${y}: ` + pixels.slice(y * 20, y * 20 + 20).join(', ')); + } + console.log('cellPixels', pixels.length); + await timeout(2000); + }); + }); + describe('selection', async () => { if (areTestsEnabled) { before(async () => setupBrowser()); @@ -890,6 +929,20 @@ async function getCellColor(col: number, row: number): Promise { return await page.evaluate(`Array.from(window.result)`); } +async function getCellPixels(col: number, row: number): Promise { + await page.evaluate(` + window.gl = window.term._core._renderService._renderer._gl; + window.result = new Uint8Array(window.d.scaledCellWidth * window.d.scaledCellHeight * 4); + window.d = window.term._core._renderService.dimensions; + window.gl.readPixels( + Math.floor(${col - 1} * window.d.scaledCellWidth), + Math.floor(window.gl.drawingBufferHeight - ${row} * window.d.scaledCellHeight), + window.d.scaledCellWidth, window.d.scaledCellHeight, window.gl.RGBA, window.gl.UNSIGNED_BYTE, window.result + ); + `); + return await page.evaluate(`Array.from(window.result)`); +} + async function setupBrowser(options: ITerminalOptions = { rendererType: 'dom' }): Promise { const browserType = getBrowserType(); browser = await browserType.launch({ diff --git a/demo/client.ts b/demo/client.ts index cc4679081..de1faa37b 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -147,6 +147,7 @@ if (document.location.pathname === '/test') { createTerminal(); document.getElementById('dispose').addEventListener('click', disposeRecreateButtonHandler); document.getElementById('serialize').addEventListener('click', serializeButtonHandler); + document.getElementById('custom-glyph').addEventListener('click', writeCustomGlyphHandler); } function createTerminal(): void { @@ -214,17 +215,16 @@ function createTerminal(): void { // Set terminal size again to set the specific dimensions on the demo updateTerminalSize(); - // fetch('/terminals?cols=' + term.cols + '&rows=' + term.rows, {method: 'POST'}).then((res) => { - // res.text().then((processId) => { - // pid = processId; - // socketURL += processId; - // socket = new WebSocket(socketURL); - // socket.onopen = runRealTerminal; - // socket.onclose = runFakeTerminal; - // socket.onerror = runFakeTerminal; - // }); - // }); - runFakeTerminal(); + fetch('/terminals?cols=' + term.cols + '&rows=' + term.rows, {method: 'POST'}).then((res) => { + res.text().then((processId) => { + pid = processId; + socketURL += processId; + socket = new WebSocket(socketURL); + socket.onopen = runRealTerminal; + socket.onclose = runFakeTerminal; + socket.onerror = runFakeTerminal; + }); + }); }, 0); } @@ -247,33 +247,11 @@ function runFakeTerminal(): void { term.write('\r\n$ '); }; - // term.writeln('Welcome to xterm.js'); - // term.writeln('This is a local terminal emulation, without a real terminal in the back-end.'); - // term.writeln('Type some keys and commands to play around.'); - // term.writeln(''); - // term.prompt(); - - term.write('Box styles: ┎┰┒┍┯┑╓╥╖╒╤╕ ┏┳┓┌┲┓┌┬┐┏┱┐\n\r'); - term.write('┌─┬─┐ ┏━┳━┓ ╔═╦═╗ ┠╂┨┝┿┥╟╫╢╞╪╡ ┡╇┩├╊┫┢╈┪┣╉┤\n\r'); - term.write('│ │ │ ┃ ┃ ┃ ║ ║ ║ ┖┸┚┕┷┙╙╨╜╘╧╛ └┴┘└┺┛┗┻┛┗┹┘\n\r'); - term.write('├─┼─┤ ┣━╋━┫ ╠═╬═╣ ┏┱┐┌┲┓┌┬┐┌┬┐ ┏┳┓┌┮┓┌┬┐┏┭┐\n\r'); - term.write('│ │ │ ┃ ┃ ┃ ║ ║ ║ ┡╃┤├╄┩├╆┪┢╅┤ ┞╀┦├┾┫┟╁┧┣┽┤\n\r'); - term.write('└─┴─┘ ┗━┻━┛ ╚═╩═╝ └┴┘└┴┘└┺┛┗┹┘ └┴┘└┶┛┗┻┛┗┵┘\n\r'); - term.write('\n\r'); - term.write('Other:\n\r'); - term.write('╭─╮ ╲ ╱ ╷╻╎╏┆┇┊┋ ╺╾╴ ╌╌╌ ┄┄┄ ┈┈┈\n\r'); - term.write('│ │ ╳ ╽╿╎╏┆┇┊┋ ╶╼╸ ╍╍╍ ┅┅┅ ┉┉┉\n\r'); - term.write('╰─╯ ╱ ╲ ╹╵╎╏┆┇┊┋\n\r'); - term.write('\n\r'); - term.write('All box drawing characters:\n\r'); - term.write('─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏\n\r'); - term.write('┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟\n\r'); - term.write('┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯\n\r'); - term.write('┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿\n\r'); - term.write('╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╌ ╍ ╎ ╏\n\r'); - term.write('═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟\n\r'); - term.write('╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯\n\r'); - term.write('╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\n\r'); + term.writeln('Welcome to xterm.js'); + term.writeln('This is a local terminal emulation, without a real terminal in the back-end.'); + term.writeln('Type some keys and commands to play around.'); + term.writeln(''); + term.prompt(); term.onKey((e: { key: string, domEvent: KeyboardEvent }) => { const ev = e.domEvent; @@ -454,3 +432,49 @@ function serializeButtonHandler(): void { term.write(output); } } + + +function writeCustomGlyphHandler() { + term.write('\n\r'); + term.write('\n\r'); + term.write('Box styles: ┎┰┒┍┯┑╓╥╖╒╤╕ ┏┳┓┌┲┓┌┬┐┏┱┐\n\r'); + term.write('┌─┬─┐ ┏━┳━┓ ╔═╦═╗ ┠╂┨┝┿┥╟╫╢╞╪╡ ┡╇┩├╊┫┢╈┪┣╉┤\n\r'); + term.write('│ │ │ ┃ ┃ ┃ ║ ║ ║ ┖┸┚┕┷┙╙╨╜╘╧╛ └┴┘└┺┛┗┻┛┗┹┘\n\r'); + term.write('├─┼─┤ ┣━╋━┫ ╠═╬═╣ ┏┱┐┌┲┓┌┬┐┌┬┐ ┏┳┓┌┮┓┌┬┐┏┭┐\n\r'); + term.write('│ │ │ ┃ ┃ ┃ ║ ║ ║ ┡╃┤├╄┩├╆┪┢╅┤ ┞╀┦├┾┫┟╁┧┣┽┤\n\r'); + term.write('└─┴─┘ ┗━┻━┛ ╚═╩═╝ └┴┘└┴┘└┺┛┗┹┘ └┴┘└┶┛┗┻┛┗┵┘\n\r'); + term.write('\n\r'); + term.write('Other:\n\r'); + term.write('╭─╮ ╲ ╱ ╷╻╎╏┆┇┊┋ ╺╾╴ ╌╌╌ ┄┄┄ ┈┈┈\n\r'); + term.write('│ │ ╳ ╽╿╎╏┆┇┊┋ ╶╼╸ ╍╍╍ ┅┅┅ ┉┉┉\n\r'); + term.write('╰─╯ ╱ ╲ ╹╵╎╏┆┇┊┋\n\r'); + term.write('\n\r'); + term.write('All box drawing characters:\n\r'); + term.write('─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏\n\r'); + term.write('┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟\n\r'); + term.write('┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯\n\r'); + term.write('┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿\n\r'); + term.write('╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╌ ╍ ╎ ╏\n\r'); + term.write('═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟\n\r'); + term.write('╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯\n\r'); + term.write('╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿\n\r'); + term.write('Box drawing alignment tests:\x1b[31m █\n\r'); + term.write(' ▉\n\r'); + term.write(' ╔══╦══╗ ┌──┬──┐ ╭──┬──╮ ╭──┬──╮ ┏━━┳━━┓ ┎┒┏┑ ╷ ╻ ┏┯┓ ┌┰┐ ▊ ╱╲╱╲╳╳╳\n\r'); + term.write(' ║┌─╨─┐║ │╔═╧═╗│ │╒═╪═╕│ │╓─╁─╖│ ┃┌─╂─┐┃ ┗╃╄┙ ╶┼╴╺╋╸┠┼┨ ┝╋┥ ▋ ╲╱╲╱╳╳╳\n\r'); + term.write(' ║│╲ ╱│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╿ │┃ ┍╅╆┓ ╵ ╹ ┗┷┛ └┸┘ ▌ ╱╲╱╲╳╳╳\n\r'); + term.write(' ╠╡ ╳ ╞╣ ├╢ ╟┤ ├┼─┼─┼┤ ├╫─╂─╫┤ ┣┿╾┼╼┿┫ ┕┛┖┚ ┌┄┄┐ ╎ ┏┅┅┓ ┋ ▍ ╲╱╲╱╳╳╳\n\r'); + term.write(' ║│╱ ╲│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╽ │┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▎\n\r'); + term.write(' ║└─╥─┘║ │╚═╤═╝│ │╘═╪═╛│ │╙─╀─╜│ ┃└─╂─┘┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▏\n\r'); + term.write(' ╚══╩══╝ └──┴──┘ ╰──┴──╯ ╰──┴──╯ ┗━━┻━━┛ └╌╌┘ ╎ ┗╍╍┛ ┋ ▁▂▃▄▅▆▇█\n\r'); + term.write('Box drawing alignment tests:\x1b[32m █\n\r'); + term.write(' ▉\n\r'); + term.write(' ╔══╦══╗ ┌──┬──┐ ╭──┬──╮ ╭──┬──╮ ┏━━┳━━┓ ┎┒┏┑ ╷ ╻ ┏┯┓ ┌┰┐ ▊ ╱╲╱╲╳╳╳\n\r'); + term.write(' ║┌─╨─┐║ │╔═╧═╗│ │╒═╪═╕│ │╓─╁─╖│ ┃┌─╂─┐┃ ┗╃╄┙ ╶┼╴╺╋╸┠┼┨ ┝╋┥ ▋ ╲╱╲╱╳╳╳\n\r'); + term.write(' ║│╲ ╱│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╿ │┃ ┍╅╆┓ ╵ ╹ ┗┷┛ └┸┘ ▌ ╱╲╱╲╳╳╳\n\r'); + term.write(' ╠╡ ╳ ╞╣ ├╢ ╟┤ ├┼─┼─┼┤ ├╫─╂─╫┤ ┣┿╾┼╼┿┫ ┕┛┖┚ ┌┄┄┐ ╎ ┏┅┅┓ ┋ ▍ ╲╱╲╱╳╳╳\n\r'); + term.write(' ║│╱ ╲│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╽ │┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▎\n\r'); + term.write(' ║└─╥─┘║ │╚═╤═╝│ │╘═╪═╛│ │╙─╀─╜│ ┃└─╂─┘┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▏\n\r'); + term.write(' ╚══╩══╝ └──┴──┘ ╰──┴──╯ ╰──┴──╯ ┗━━┻━━┛ └╌╌┘ ╎ ┗╍╍┛ ┋ ▁▂▃▄▅▆▇█\n\r'); + window.scrollTo(0, 0); +} diff --git a/demo/index.html b/demo/index.html index ab5b20406..910397c33 100644 --- a/demo/index.html +++ b/demo/index.html @@ -50,6 +50,7 @@
+ diff --git a/src/browser/renderer/CustomGlyphs.ts b/src/browser/renderer/CustomGlyphs.ts index 7457441b0..82e086c45 100644 --- a/src/browser/renderer/CustomGlyphs.ts +++ b/src/browser/renderer/CustomGlyphs.ts @@ -330,7 +330,6 @@ export function tryDrawCustomChar( const patternDefinition = patternCharacterDefinitions[c]; if (patternDefinition) { - console.log('draw pattern', c); drawPatternChar(ctx, patternDefinition, xOffset, yOffset, scaledCellWidth, scaledCellHeight); return true; } From 158dcb06bdcf68bcfafcec872861f1773fa8f848 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 19 Aug 2021 05:16:01 -0700 Subject: [PATCH 115/164] Remove custom glyph tests --- .../test/WebglRenderer.api.ts | 39 ------------------- 1 file changed, 39 deletions(-) diff --git a/addons/xterm-addon-webgl/test/WebglRenderer.api.ts b/addons/xterm-addon-webgl/test/WebglRenderer.api.ts index b666ceb41..48f9c3d07 100644 --- a/addons/xterm-addon-webgl/test/WebglRenderer.api.ts +++ b/addons/xterm-addon-webgl/test/WebglRenderer.api.ts @@ -830,45 +830,6 @@ describe('WebGL Renderer Integration Tests', async () => { }); }); - describe.only('custom glyphs', () => { - if (areTestsEnabled) { - before(async () => setupBrowser()); - after(async () => browser.close()); - beforeEach(async () => page.evaluate(`window.term.reset()`)); - } - - itWebgl('should draw normal weight characters pixel perfect', async () => { - const theme: ITheme = { - background: '#000000', - foreground: '#ffffff' - }; - await page.evaluate(` - window.term.setOption('theme', ${JSON.stringify(theme)}); - window.term.setOption('fontSize', 12); - window.term.setOption('minimumContrastRatio', 1); - `); - await writeSync(page, - 'Box drawing alignment tests: █\\n\\r' + - ' ▉\\n\\r' + - ' ╔══╦══╗ ┌──┬──┐ ╭──┬──╮ ╭──┬──╮ ┏━━┳━━┓ ┎┒┏┑ ╷ ╻ ┏┯┓ ┌┰┐ ▊ ╱╲╱╲╳╳╳\\n\\r' + - ' ║┌─╨─┐║ │╔═╧═╗│ │╒═╪═╕│ │╓─╁─╖│ ┃┌─╂─┐┃ ┗╃╄┙ ╶┼╴╺╋╸┠┼┨ ┝╋┥ ▋ ╲╱╲╱╳╳╳\\n\\r' + - ' ║│╲ ╱│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╿ │┃ ┍╅╆┓ ╵ ╹ ┗┷┛ └┸┘ ▌ ╱╲╱╲╳╳╳\\n\\r' + - ' ╠╡ ╳ ╞╣ ├╢ ╟┤ ├┼─┼─┼┤ ├╫─╂─╫┤ ┣┿╾┼╼┿┫ ┕┛┖┚ ┌┄┄┐ ╎ ┏┅┅┓ ┋ ▍ ╲╱╲╱╳╳╳\\n\\r' + - ' ║│╱ ╲│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╽ │┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▎\\n\\r' + - ' ║└─╥─┘║ │╚═╤═╝│ │╘═╪═╛│ │╙─╀─╜│ ┃└─╂─┘┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▏\\n\\r' + - ' ╚══╩══╝ └──┴──┘ ╰──┴──╯ ╰──┴──╯ ┗━━┻━━┛ └╌╌┘ ╎ ┗╍╍┛ ┋ ▁▂▃▄▅▆▇█' - ); - // Validate before minimumContrastRatio is applied - await pollFor(page, () => getCellColor(1, 1), [0x2e, 0x34, 0x36, 255]); - const pixels = await getCellPixels(1, 1); - for (let y = 0; y < pixels.length / 20; y++) { - console.log(`pixels ${y}: ` + pixels.slice(y * 20, y * 20 + 20).join(', ')); - } - console.log('cellPixels', pixels.length); - await timeout(2000); - }); - }); - describe('selection', async () => { if (areTestsEnabled) { before(async () => setupBrowser()); From 3be97841a3c91178b7a3e88425a0c32498150b41 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 19 Aug 2021 05:19:28 -0700 Subject: [PATCH 116/164] Rename setting customGlyphs --- addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts | 4 ++-- addons/xterm-addon-webgl/src/atlas/Types.d.ts | 2 +- addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts | 2 +- src/browser/Terminal.ts | 2 +- src/browser/renderer/BaseRenderLayer.ts | 4 ++-- src/common/services/OptionsService.ts | 2 +- src/common/services/Services.ts | 2 +- typings/xterm-headless.d.ts | 10 +++++----- typings/xterm.d.ts | 10 +++++----- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts b/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts index 6a4783383..962eb7b34 100644 --- a/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts +++ b/addons/xterm-addon-webgl/src/atlas/CharAtlasUtils.ts @@ -28,7 +28,7 @@ export function generateConfig(scaledCellWidth: number, scaledCellHeight: number contrastCache: colors.contrastCache }; return { - customBlockAndBoxCharacters: terminal.getOption('customBlockAndBoxCharacters'), + customGlyphs: terminal.getOption('customGlyphs'), devicePixelRatio: window.devicePixelRatio, letterSpacing: terminal.getOption('letterSpacing'), lineHeight: terminal.getOption('lineHeight'), @@ -54,7 +54,7 @@ export function configEquals(a: ICharAtlasConfig, b: ICharAtlasConfig): boolean } } return a.devicePixelRatio === b.devicePixelRatio && - a.customBlockAndBoxCharacters === b.customBlockAndBoxCharacters && + a.customGlyphs === b.customGlyphs && a.lineHeight === b.lineHeight && a.letterSpacing === b.letterSpacing && a.fontFamily === b.fontFamily && diff --git a/addons/xterm-addon-webgl/src/atlas/Types.d.ts b/addons/xterm-addon-webgl/src/atlas/Types.d.ts index acbe3c71b..8d2870cde 100644 --- a/addons/xterm-addon-webgl/src/atlas/Types.d.ts +++ b/addons/xterm-addon-webgl/src/atlas/Types.d.ts @@ -17,7 +17,7 @@ export interface IGlyphIdentifier { } export interface ICharAtlasConfig { - customBlockAndBoxCharacters: boolean; + customGlyphs: boolean; devicePixelRatio: number; letterSpacing: number; lineHeight: number; diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 557e23ef2..4c45fce18 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -393,7 +393,7 @@ export class WebglCharAtlas implements IDisposable { // Draw custom characters if applicable let drawSuccess = false; - if (this._config.customBlockAndBoxCharacters !== false) { + if (this._config.customGlyphs !== false) { drawSuccess = tryDrawCustomChar(this._tmpCtx, chars, TMP_CANVAS_GLYPH_PADDING, TMP_CANVAS_GLYPH_PADDING, this._config.scaledCellWidth, this._config.scaledCellHeight); } diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 3ab343da5..dde4a1b6e 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -224,7 +224,7 @@ export class Terminal extends CoreTerminal implements ITerminal { // The DOM renderer needs a row refresh to update the cursor styles this.refresh(this.buffer.y, this.buffer.y); break; - case 'customBlockAndBoxCharacters': + case 'customGlyphs': case 'drawBoldTextInBrightColors': case 'letterSpacing': case 'lineHeight': diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 117213eb3..448451d01 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -263,7 +263,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { // Draw custom characters if applicable let drawSuccess = false; - if (this._optionsService.options.customBlockAndBoxCharacters !== false) { + if (this._optionsService.options.customGlyphs !== false) { drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); } @@ -387,7 +387,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { // Draw custom characters if applicable let drawSuccess = false; - if (this._optionsService.options.customBlockAndBoxCharacters !== false) { + if (this._optionsService.options.customGlyphs !== false) { drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); } diff --git a/src/common/services/OptionsService.ts b/src/common/services/OptionsService.ts index 062166bc9..5add82833 100644 --- a/src/common/services/OptionsService.ts +++ b/src/common/services/OptionsService.ts @@ -21,7 +21,7 @@ export const DEFAULT_OPTIONS: ITerminalOptions = Object.freeze({ cursorBlink: false, cursorStyle: 'block', cursorWidth: 1, - customBlockAndBoxCharacters: true, + customGlyphs: true, bellSound: DEFAULT_BELL_SOUND, bellStyle: 'none', drawBoldTextInBrightColors: true, diff --git a/src/common/services/Services.ts b/src/common/services/Services.ts index 07615a413..2190a0f8f 100644 --- a/src/common/services/Services.ts +++ b/src/common/services/Services.ts @@ -244,7 +244,7 @@ export interface ITerminalOptions { cursorBlink: boolean; cursorStyle: 'block' | 'underline' | 'bar'; cursorWidth: number; - customBlockAndBoxCharacters: boolean; + customGlyphs: boolean; disableStdin: boolean; drawBoldTextInBrightColors: boolean; fastScrollModifier: 'alt' | 'ctrl' | 'shift' | undefined; diff --git a/typings/xterm-headless.d.ts b/typings/xterm-headless.d.ts index dc886aa1d..13a321261 100644 --- a/typings/xterm-headless.d.ts +++ b/typings/xterm-headless.d.ts @@ -79,12 +79,12 @@ declare module 'xterm-headless' { cursorWidth?: number; /** - * Whether to draw custom block element and box drawing characters instead of using the font. - * This should typically result in better rendering with continuous lines. Note that this - * doesn't work with the DOM renderer which renders all characters using the font. The default - * is true. + * Whether to draw custom glyphs for block element and box drawing characters instead of using + * the font. This should typically result in better rendering with continuous lines, even when + * line height and letter spacing is used. Note that this doesn't work with the DOM renderer + * which renders all characters using the font. The default is true. */ - customBlockAndBoxCharacters?: boolean; + customGlyphs?: boolean; /** * Whether input should be disabled. diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index f6fbe709d..ba2be9881 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -91,12 +91,12 @@ declare module 'xterm' { cursorWidth?: number; /** - * Whether to draw custom block element and box drawing characters instead of using the font. - * This should typically result in better rendering with continuous lines. Note that this - * doesn't work with the DOM renderer which renders all characters using the font. The default - * is true. + * Whether to draw custom glyphs for block element and box drawing characters instead of using + * the font. This should typically result in better rendering with continuous lines, even when + * line height and letter spacing is used. Note that this doesn't work with the DOM renderer + * which renders all characters using the font. The default is true. */ - customBlockAndBoxCharacters?: boolean; + customGlyphs?: boolean; /** * Whether input should be disabled. From 24cbedb71528bc2d65b7c200af7ae1eac1fe85ab Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 19 Aug 2021 05:32:46 -0700 Subject: [PATCH 117/164] Fix custom glyphs when using transparency --- .../test/WebglRenderer.api.ts | 6 ++-- src/browser/renderer/CustomGlyphs.ts | 30 ++++++++++++++----- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/addons/xterm-addon-webgl/test/WebglRenderer.api.ts b/addons/xterm-addon-webgl/test/WebglRenderer.api.ts index 48f9c3d07..793929e93 100644 --- a/addons/xterm-addon-webgl/test/WebglRenderer.api.ts +++ b/addons/xterm-addon-webgl/test/WebglRenderer.api.ts @@ -3,11 +3,11 @@ * @license MIT */ -import { ITerminalOptions } from '../../../src/common/Types'; -import { ITheme } from 'xterm'; import { assert } from 'chai'; -import { openTerminal, pollFor, writeSync, getBrowserType, timeout } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; +import { ITheme } from 'xterm'; +import { getBrowserType, openTerminal, pollFor, writeSync } from '../../../out-test/api/TestUtils'; +import { ITerminalOptions } from '../../../src/common/Types'; const APP = 'http://127.0.0.1:3001/test'; diff --git a/src/browser/renderer/CustomGlyphs.ts b/src/browser/renderer/CustomGlyphs.ts index 82e086c45..a132877a5 100644 --- a/src/browser/renderer/CustomGlyphs.ts +++ b/src/browser/renderer/CustomGlyphs.ts @@ -379,8 +379,10 @@ function drawPatternChar( patternSet = new Map(); cachedPatterns.set(charDefinition, patternSet); } - // TODO: Unsafe? - const fillStyle = ctx.fillStyle as string; + const fillStyle = ctx.fillStyle; + if (typeof fillStyle !== 'string') { + throw new Error(`Unexpected fillStyle type "${fillStyle}"`); + } let pattern = patternSet.get(fillStyle); if (!pattern) { const width = charDefinition[0].length; @@ -390,17 +392,29 @@ function drawPatternChar( tmpCanvas.height = height; const tmpCtx = throwIfFalsy(tmpCanvas.getContext('2d')); const imageData = new ImageData(width, height); - // TODO: This is a little unsafe, fillStyle could be rgb/rgba format - const r = parseInt(fillStyle.substr(1, 2), 16); - const g = parseInt(fillStyle.substr(3, 2), 16); - const b = parseInt(fillStyle.substr(5, 2), 16); - const a = fillStyle.length > 7 && parseInt(fillStyle.substr(7, 2), 16) || undefined; + + // Extract rgba from fillStyle + let r: number; + let g: number; + let b: number; + let a: number; + if (fillStyle.startsWith('#')) { + r = parseInt(fillStyle.substr(1, 2), 16); + g = parseInt(fillStyle.substr(3, 2), 16); + b = parseInt(fillStyle.substr(5, 2), 16); + a = fillStyle.length > 7 && parseInt(fillStyle.substr(7, 2), 16) || 1; + } else if (fillStyle.startsWith('rgba')) { + ([r, g, b, a] = fillStyle.substring(5, fillStyle.length - 1).split(',').map(e => parseFloat(e))); + } else { + throw new Error(`Unexpected fillStyle color format "${fillStyle}" when drawing pattern glyph`); + } + for (let y = 0; y < height; y++) { for (let x = 0; x < width; x++) { imageData.data[(y * width + x) * 4 ] = r; imageData.data[(y * width + x) * 4 + 1] = g; imageData.data[(y * width + x) * 4 + 2] = b; - imageData.data[(y * width + x) * 4 + 3] = charDefinition[y][x] * (a ?? 255); + imageData.data[(y * width + x) * 4 + 3] = charDefinition[y][x] * (a * 255); } } tmpCtx.putImageData(imageData, 0, 0); From 338d94daf9be0aed05e1d15b4d47dd6f6b090e43 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 19 Aug 2021 05:41:49 -0700 Subject: [PATCH 118/164] Fix webgl alignment issues No idea why this worked but it did --- addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 4c45fce18..340e83c9f 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -394,7 +394,7 @@ export class WebglCharAtlas implements IDisposable { // Draw custom characters if applicable let drawSuccess = false; if (this._config.customGlyphs !== false) { - drawSuccess = tryDrawCustomChar(this._tmpCtx, chars, TMP_CANVAS_GLYPH_PADDING, TMP_CANVAS_GLYPH_PADDING, this._config.scaledCellWidth, this._config.scaledCellHeight); + drawSuccess = tryDrawCustomChar(this._tmpCtx, chars, padding, padding, this._config.scaledCellWidth, this._config.scaledCellHeight); } // Draw the character From 1a75416dbfe762f32aeeb2ee5faccafe80583841 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 19 Aug 2021 06:00:27 -0700 Subject: [PATCH 119/164] Add missing block elements (include all 0x2580-0x259F) --- src/browser/renderer/CustomGlyphs.ts | 61 +++++++++++++++++----------- 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/src/browser/renderer/CustomGlyphs.ts b/src/browser/renderer/CustomGlyphs.ts index a132877a5..775627900 100644 --- a/src/browser/renderer/CustomGlyphs.ts +++ b/src/browser/renderer/CustomGlyphs.ts @@ -13,22 +13,40 @@ interface IBlockVector { } export const blockElementDefinitions: { [index: string]: IBlockVector[] | undefined } = { - '▀': [{ x: 0, y: 0, w: 8, h: 4 }], - '█': [{ x: 0, y: 0, w: 8, h: 8 }], - '▇': [{ x: 0, y: 1, w: 8, h: 7 }], - '▆': [{ x: 0, y: 2, w: 8, h: 6 }], - '▅': [{ x: 0, y: 3, w: 8, h: 5 }], - '▄': [{ x: 0, y: 4, w: 8, h: 4 }], - '▃': [{ x: 0, y: 5, w: 8, h: 3 }], - '▂': [{ x: 0, y: 6, w: 8, h: 2 }], - '▁': [{ x: 0, y: 7, w: 8, h: 1 }], - '▉': [{ x: 0, y: 0, w: 7, h: 8 }], - '▊': [{ x: 0, y: 0, w: 6, h: 8 }], - '▋': [{ x: 0, y: 0, w: 5, h: 8 }], - '▌': [{ x: 0, y: 0, w: 4, h: 8 }], - '▍': [{ x: 0, y: 0, w: 3, h: 8 }], - '▎': [{ x: 0, y: 0, w: 2, h: 8 }], - '▏': [{ x: 0, y: 0, w: 1, h: 8 }], + // Block elements (0x2580-0x2590) + '▀': [{ x: 0, y: 0, w: 8, h: 4 }], // UPPER HALF BLOCK + '▁': [{ x: 0, y: 7, w: 8, h: 1 }], // LOWER ONE EIGHTH BLOCK + '▂': [{ x: 0, y: 6, w: 8, h: 2 }], // LOWER ONE QUARTER BLOCK + '▃': [{ x: 0, y: 5, w: 8, h: 3 }], // LOWER THREE EIGHTHS BLOCK + '▄': [{ x: 0, y: 4, w: 8, h: 4 }], // LOWER HALF BLOCK + '▅': [{ x: 0, y: 3, w: 8, h: 5 }], // LOWER FIVE EIGHTHS BLOCK + '▆': [{ x: 0, y: 2, w: 8, h: 6 }], // LOWER THREE QUARTERS BLOCK + '▇': [{ x: 0, y: 1, w: 8, h: 7 }], // LOWER SEVEN EIGHTHS BLOCK + '█': [{ x: 0, y: 0, w: 8, h: 8 }], // FULL BLOCK + '▉': [{ x: 0, y: 0, w: 7, h: 8 }], // LEFT SEVEN EIGHTHS BLOCK + '▊': [{ x: 0, y: 0, w: 6, h: 8 }], // LEFT THREE QUARTERS BLOCK + '▋': [{ x: 0, y: 0, w: 5, h: 8 }], // LEFT FIVE EIGHTHS BLOCK + '▌': [{ x: 0, y: 0, w: 4, h: 8 }], // LEFT HALF BLOCK + '▍': [{ x: 0, y: 0, w: 3, h: 8 }], // LEFT THREE EIGHTHS BLOCK + '▎': [{ x: 0, y: 0, w: 2, h: 8 }], // LEFT ONE QUARTER BLOCK + '▏': [{ x: 0, y: 0, w: 1, h: 8 }], // LEFT ONE EIGHTH BLOCK + '▐': [{ x: 4, y: 0, w: 4, h: 8 }], // RIGHT HALF BLOCK + + // Block elements (0x2594-0x2595) + '▔': [{ x: 0, y: 0, w: 9, h: 1 }], // UPPER ONE EIGHTH BLOCK + '▕': [{ x: 7, y: 0, w: 1, h: 8 }], // RIGHT ONE EIGHTH BLOCK + + // Terminal graphic characters (0x2596-0x259F) + '▖': [{ x: 0, y: 4, w: 4, h: 4 }], // QUADRANT LOWER LEFT + '▗': [{ x: 4, y: 4, w: 4, h: 4 }], // QUADRANT LOWER RIGHT + '▘': [{ x: 0, y: 0, w: 4, h: 4 }], // QUADRANT UPPER LEFT + '▙': [{ x: 0, y: 0, w: 4, h: 8 }, { x: 0, y: 4, w: 8, h: 4 }], // QUADRANT UPPER LEFT AND LOWER LEFT AND LOWER RIGHT + '▚': [{ x: 0, y: 0, w: 4, h: 4 }, { x: 4, y: 4, w: 4, h: 4 }], // QUADRANT UPPER LEFT AND LOWER RIGHT + '▛': [{ x: 0, y: 0, w: 4, h: 8 }, { x: 0, y: 0, w: 4, h: 8 }], // QUADRANT UPPER LEFT AND UPPER RIGHT AND LOWER LEFT + '▜': [{ x: 0, y: 0, w: 8, h: 4 }, { x: 4, y: 0, w: 4, h: 8 }], // QUADRANT UPPER LEFT AND UPPER RIGHT AND LOWER RIGHT + '▝': [{ x: 4, y: 0, w: 4, h: 4 }], // QUADRANT UPPER RIGHT + '▞': [{ x: 4, y: 0, w: 4, h: 4 }, { x: 0, y: 4, w: 4, h: 4 }], // QUADRANT UPPER RIGHT AND LOWER LEFT + '▟': [{ x: 4, y: 0, w: 4, h: 8 }, { x: 0, y: 4, w: 8, h: 4 }], // QUADRANT UPPER RIGHT AND LOWER LEFT AND LOWER RIGHT // VERTICAL ONE EIGHTH BLOCK-2 through VERTICAL ONE EIGHTH BLOCK-7 '\u{1FB70}': [{ x: 1, y: 0, w: 1, h: 8 }], @@ -37,11 +55,7 @@ export const blockElementDefinitions: { [index: string]: IBlockVector[] | undefi '\u{1FB73}': [{ x: 4, y: 0, w: 1, h: 8 }], '\u{1FB74}': [{ x: 5, y: 0, w: 1, h: 8 }], '\u{1FB75}': [{ x: 6, y: 0, w: 1, h: 8 }], - // RIGHT ONE EIGHTH BLOCK - '▕': [{ x: 7, y: 0, w: 1, h: 8 }], - // UPPER ONE EIGHTH BLOCK - '▔': [{ x: 0, y: 0, w: 8, h: 1 }], // HORIZONTAL ONE EIGHTH BLOCK-2 through HORIZONTAL ONE EIGHTH BLOCK-7 '\u{1FB76}': [{ x: 0, y: 1, w: 8, h: 1 }], '\u{1FB77}': [{ x: 0, y: 2, w: 8, h: 1 }], @@ -110,19 +124,20 @@ type PatternDefinition = number[][]; * pixel values to be filled (1) or not filled (0). */ const patternCharacterDefinitions: { [key: string]: PatternDefinition | undefined } = { - '░': [ + // Shade characters (0x2591-0x2593) + '░': [ // LIGHT SHADE (25%) [1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, 0], [0, 0, 0, 0] ], - '▒': [ + '▒': [ // MEDIUM SHADE (50%) [1, 0], [0, 0], [0, 1], [0, 0] ], - '▓': [ + '▓': [ // DARK SHADE (75%) [0, 1], [1, 1], [1, 0], From 53dbcbafb2b7e39dc29631f892a5df09390ea131 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 19 Aug 2021 07:05:42 -0700 Subject: [PATCH 120/164] Ensure underscore is within cell bounds Fixes #3423 --- .../src/atlas/WebglCharAtlas.ts | 16 +++++++++++++ .../renderer/atlas/DynamicCharAtlas.ts | 24 +++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 340e83c9f..33a819fb0 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -402,6 +402,22 @@ export class WebglCharAtlas implements IDisposable { this._tmpCtx.fillText(chars, padding, padding + this._config.scaledCharHeight); } + // If this charcater is underscore and beyond the cell bounds, shift it up until it is visible, + // try for a maximum of 5 pixels. + if (chars === '_' && !this._config.allowTransparency) { + let isBeyondCellBounds = clearColor(this._tmpCtx.getImageData(padding, padding, this._config.scaledCellWidth, this._config.scaledCellHeight), backgroundColor); + if (isBeyondCellBounds) { + for (let offset = 1; offset <= 5; offset++) { + this._tmpCtx.clearRect(0, 0, this._tmpCanvas.width, this._tmpCanvas.height); + this._tmpCtx.fillText(chars, padding, padding + this._config.scaledCharHeight - offset); + isBeyondCellBounds = clearColor(this._tmpCtx.getImageData(padding, padding, this._config.scaledCellWidth, this._config.scaledCellHeight), backgroundColor); + if (!isBeyondCellBounds) { + break; + } + } + } + } + // Draw underline and strikethrough if (underline || strikethrough) { const lineWidth = Math.max(1, Math.floor(this._config.fontSize / 10)); diff --git a/src/browser/renderer/atlas/DynamicCharAtlas.ts b/src/browser/renderer/atlas/DynamicCharAtlas.ts index 883ebe785..a72378785 100644 --- a/src/browser/renderer/atlas/DynamicCharAtlas.ts +++ b/src/browser/renderer/atlas/DynamicCharAtlas.ts @@ -266,11 +266,10 @@ export class DynamicCharAtlas extends BaseCharAtlas { } // Draw the character this._tmpCtx.fillText(glyph.chars, 0, this._config.scaledCharHeight); - this._tmpCtx.restore(); // clear the background from the character to avoid issues with drawing over the previous // character if it extends past it's bounds - const imageData = this._tmpCtx.getImageData( + let imageData = this._tmpCtx.getImageData( 0, 0, this._config.scaledCharWidth, this._config.scaledCharHeight ); let isEmpty = false; @@ -278,6 +277,27 @@ export class DynamicCharAtlas extends BaseCharAtlas { isEmpty = clearColor(imageData, backgroundColor); } + // If this charcater is underscore and empty, shift it up until it is visible, try for a maximum + // of 5 pixels. + if (isEmpty && glyph.chars === '_' && !this._config.allowTransparency) { + for (let offset = 1; offset <= 5; offset++) { + // Draw the character + this._tmpCtx.fillText(glyph.chars, 0, this._config.scaledCharHeight - offset); + + // clear the background from the character to avoid issues with drawing over the previous + // character if it extends past it's bounds + imageData = this._tmpCtx.getImageData( + 0, 0, this._config.scaledCharWidth, this._config.scaledCharHeight + ); + isEmpty = clearColor(imageData, backgroundColor); + if (!isEmpty) { + break; + } + } + } + + this._tmpCtx.restore(); + // copy the data from imageData to _cacheCanvas const x = this._toCoordinateX(index); const y = this._toCoordinateY(index); From c1413ce58dcb92611eb28fb5c8109d8828e04f70 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Thu, 19 Aug 2021 18:24:49 -0700 Subject: [PATCH 121/164] fix #3427 --- addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 33a819fb0..6128c8369 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -459,7 +459,7 @@ export class WebglCharAtlas implements IDisposable { return NULL_RASTERIZED_GLYPH; } - const rasterizedGlyph = this._findGlyphBoundingBox(imageData, this._workBoundingBox, allowedWidth, isPowerlineGlyph); + const rasterizedGlyph = this._findGlyphBoundingBox(imageData, this._workBoundingBox, allowedWidth, isPowerlineGlyph, drawSuccess); const clippedImageData = this._clipImageData(imageData, this._workBoundingBox); // Check if there is enough room in the current row and go to next if needed @@ -492,7 +492,7 @@ export class WebglCharAtlas implements IDisposable { * @param imageData The image data to read. * @param boundingBox An IBoundingBox to put the clipped bounding box values. */ - private _findGlyphBoundingBox(imageData: ImageData, boundingBox: IBoundingBox, allowedWidth: number, restrictedGlyph: boolean): IRasterizedGlyph { + private _findGlyphBoundingBox(imageData: ImageData, boundingBox: IBoundingBox, allowedWidth: number, restrictedGlyph: boolean, customGlyph: boolean): IRasterizedGlyph { boundingBox.top = 0; const height = restrictedGlyph ? this._config.scaledCharHeight : this._tmpCanvas.height; const width = restrictedGlyph ? this._config.scaledCharWidth : allowedWidth; @@ -567,8 +567,8 @@ export class WebglCharAtlas implements IDisposable { y: (boundingBox.bottom - boundingBox.top + 1) / TEXTURE_HEIGHT }, offset: { - x: -boundingBox.left + (restrictedGlyph ? 0 : TMP_CANVAS_GLYPH_PADDING), - y: -boundingBox.top + (restrictedGlyph ? 0 : TMP_CANVAS_GLYPH_PADDING) + x: -boundingBox.left + (restrictedGlyph ? 0 : TMP_CANVAS_GLYPH_PADDING) + (customGlyph ? Math.floor(this._config.letterSpacing / 2) : 0), + y: -boundingBox.top + (restrictedGlyph ? 0 : TMP_CANVAS_GLYPH_PADDING) + (customGlyph ? this._config.lineHeight === 1 ? 0 : Math.round((this._config.scaledCellHeight - this._config.scaledCharHeight) / 2) : 0) } }; } From f0636ed083e0fb7bdfdd0ab09c080b71567675b1 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sun, 22 Aug 2021 17:15:00 +0200 Subject: [PATCH 122/164] input: handle dead keys --- src/browser/Terminal.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index dde4a1b6e..2a81d9285 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -94,6 +94,13 @@ export class Terminal extends CoreTerminal implements ITerminal { */ private _keyDownHandled: boolean = false; + /** + * Records whether there has been a keydown event for a dead key without a corresponding keydown + * event for the composed/alternative character. If we cancel the keydown event for the dead key, + * no events will be emitted for the final character. + */ + private _unprocessedDeadKey: boolean = false; + public linkifier: ILinkifier; public linkifier2: ILinkifier2; public viewport: IViewport | undefined; @@ -1025,6 +1032,10 @@ export class Terminal extends CoreTerminal implements ITerminal { return false; } + if (event.key === 'Dead') { + this._unprocessedDeadKey = true; + } + const result = evaluateKeyboardEvent(event, this.coreService.decPrivateModes.applicationCursorKeys, this.browser.isMac, this.options.macOptionIsMeta); this.updateCursorStyle(event); @@ -1052,6 +1063,11 @@ export class Terminal extends CoreTerminal implements ITerminal { return true; } + if (this._unprocessedDeadKey) { + this._unprocessedDeadKey = false; + return true; + } + // If ctrl+c or enter is being sent, clear out the textarea. This is done so that screen readers // will announce deleted characters. This will not work 100% of the time but it should cover // most scenarios. From b3cd4948ad46c5c504ff5039714a420fb84068d9 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sun, 22 Aug 2021 16:19:17 +0200 Subject: [PATCH 123/164] input: handle input from macOS and Windows emoji panels --- src/browser/Terminal.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index dde4a1b6e..6d31345be 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -94,6 +94,13 @@ export class Terminal extends CoreTerminal implements ITerminal { */ private _keyDownHandled: boolean = false; + /** + * Records whether the keypress event has already been handled and triggered a data event, if so + * the input event should not trigger a data event but should still print to the textarea so + * screen readers will announce it. + */ + private _keyPressHandled: boolean = false; + public linkifier: ILinkifier; public linkifier2: ILinkifier2; public viewport: IViewport | undefined; @@ -383,6 +390,7 @@ export class Terminal extends CoreTerminal implements ITerminal { this.register(addDisposableDomListener(this.textarea!, 'compositionstart', () => this._compositionHelper!.compositionstart())); this.register(addDisposableDomListener(this.textarea!, 'compositionupdate', (e: CompositionEvent) => this._compositionHelper!.compositionupdate(e))); this.register(addDisposableDomListener(this.textarea!, 'compositionend', () => this._compositionHelper!.compositionend())); + this.register(addDisposableDomListener(this.textarea!, 'input', (ev: InputEvent) => this._inputEvent(ev), true)); this.register(this.onRender(() => this._compositionHelper!.updateCompositionElements())); this.register(this.onRender(e => this._queueLinkification(e.start, e.end))); } @@ -1097,6 +1105,7 @@ export class Terminal extends CoreTerminal implements ITerminal { } this.updateCursorStyle(ev); + this._keyPressHandled = false; } /** @@ -1108,6 +1117,8 @@ export class Terminal extends CoreTerminal implements ITerminal { protected _keyPress(ev: KeyboardEvent): boolean { let key; + this._keyPressHandled = false; + if (this._keyDownHandled) { return false; } @@ -1140,9 +1151,33 @@ export class Terminal extends CoreTerminal implements ITerminal { this._showCursor(); this.coreService.triggerDataEvent(key, true); + this._keyPressHandled = true; + return true; } + /** + * Handle an input event. + * Key Resources: + * - https://developer.mozilla.org/en-US/docs/Web/API/InputEvent + * @param ev The input event to be handled. + */ + protected _inputEvent(ev: InputEvent): boolean { + if (ev.data && ev.inputType === 'insertText') { + if (this._keyPressHandled) { + return false; + } + + const text = ev.data; + this.coreService.triggerDataEvent(text, true); + + this.cancel(ev); + return true; + } + + return false; + } + /** * Ring the bell. * Note: We could do sweet things with webaudio here From 44be1f5d2a373eba9aceb88394f1fedc769a7518 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 23 Aug 2021 05:23:17 -0700 Subject: [PATCH 124/164] Add repository key to serialize package.json Not having this breaks some of vscode's tooling --- addons/xterm-addon-serialize/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/xterm-addon-serialize/package.json b/addons/xterm-addon-serialize/package.json index 770771c4c..91ef26afd 100644 --- a/addons/xterm-addon-serialize/package.json +++ b/addons/xterm-addon-serialize/package.json @@ -7,6 +7,7 @@ }, "main": "lib/xterm-addon-serialize.js", "types": "typings/xterm-addon-serialize.d.ts", + "repository": "https://github.com/xtermjs/xterm.js", "license": "MIT", "scripts": { "build": "../../node_modules/.bin/tsc -p .", From fa9126c4e6c19cfb9276cd1ecbbef06eac34cc78 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Wed, 25 Aug 2021 21:48:25 +0200 Subject: [PATCH 125/164] input: support AltGraph as a third level shift modifier --- src/browser/Terminal.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 2a81d9285..fc7251229 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -1090,10 +1090,11 @@ export class Terminal extends CoreTerminal implements ITerminal { this._keyDownHandled = true; } - private _isThirdLevelShift(browser: IBrowser, ev: IKeyboardEvent): boolean { + private _isThirdLevelShift(browser: IBrowser, ev: KeyboardEvent): boolean { const thirdLevelKey = (browser.isMac && !this.options.macOptionIsMeta && ev.altKey && !ev.ctrlKey && !ev.metaKey) || - (browser.isWindows && ev.altKey && ev.ctrlKey && !ev.metaKey); + (browser.isWindows && ev.altKey && ev.ctrlKey && !ev.metaKey) || + (browser.isWindows && ev.getModifierState('AltGraph')); if (ev.type === 'keypress') { return thirdLevelKey; From f2ef2b0b040c043ef786629f45cf5bfa0d012199 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sat, 28 Aug 2021 14:13:27 +0200 Subject: [PATCH 126/164] input: treat AltGraph as a dead key too --- src/browser/Terminal.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 2a81d9285..b8d2091bb 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -1032,7 +1032,7 @@ export class Terminal extends CoreTerminal implements ITerminal { return false; } - if (event.key === 'Dead') { + if (event.key === 'Dead' || event.key === 'AltGraph') { this._unprocessedDeadKey = true; } From 2be3fc82bacce610b786fe7d4cf8db47e2466077 Mon Sep 17 00:00:00 2001 From: Simran Narang Date: Mon, 30 Aug 2021 15:14:15 +0530 Subject: [PATCH 127/164] Terminal controls shifted to the right of the demo The terminals have been shifted using a fixed tab bar on the right side of the demo. --- demo/index.html | 99 +++++++++++++++++++++++++++++++------------------ demo/style.css | 49 ++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 36 deletions(-) diff --git a/demo/index.html b/demo/index.html index 910397c33..621a1883b 100644 --- a/demo/index.html +++ b/demo/index.html @@ -15,42 +15,69 @@

xterm.js: A terminal for the web

-
-
-

Options

-

These options can be set in the Terminal constructor or by using the Terminal.setOption function.

-
-
-
-

Addons

-

Addons can be loaded and unloaded on a particular terminal to extend its functionality.

-
-

Addons Control

-

SearchAddon

-

- - - - - -

-

SerializeAddon

-

- - -

-

-
-
-

Style

-
- - +
+
+
+
+
+
+ + + +
+
+

Options

+

These options can be set in the Terminal constructor or by using the Terminal.setOption function.

+
+
+
+

Addons

+

Addons can be loaded and unloaded on a particular terminal to extend its functionality.

+
+

Addons Control

+

SearchAddon

+

+ + + + + +

+

SerializeAddon

+

+ + +

+

+
+
+

Style

+
+ + +
+
-
- - - - +
+ + + + + diff --git a/demo/style.css b/demo/style.css index 9c5fd0bd6..29c4cbb1c 100644 --- a/demo/style.css +++ b/demo/style.css @@ -41,3 +41,52 @@ pre { word-wrap: break-word; white-space: pre-wrap; } + + +#container { + display: flex; + height: 75vh; +} +#grid { + flex: 1; + /* max-height: 80vh; + overflow-y: auto; */ + width: 100%; +} +.tab { + overflow: hidden; + border: 1px solid #ccc; + background-color: #f1f1f1; +} + +/* Style the buttons inside the tab */ +.tab button { + background-color: inherit; + float: left; + border: none; + outline: none; + cursor: pointer; + padding: 14px 16px; + transition: 0.3s; + font-size: 17px; +} + +/* Change background color of buttons on hover */ +.tab button:hover { + background-color: #ddd; +} + +/* Create an active/current tablink class */ +.tab button.active { + background-color: #ccc; + } + +/* Style the tab content */ +.tabContent { + display: none; + padding: 6px 12px; + border: 1px solid #ccc; + border-top: none; + max-height: 67.7vh; + overflow-y: auto; +} From 640ea60945794aaadc17acc14bcc8f5673989b5d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 30 Aug 2021 10:48:12 -0700 Subject: [PATCH 128/164] Action feedback --- src/browser/Viewport.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/browser/Viewport.ts b/src/browser/Viewport.ts index 77325ef9c..9ce14daf7 100644 --- a/src/browser/Viewport.ts +++ b/src/browser/Viewport.ts @@ -23,6 +23,7 @@ export class Viewport extends Disposable implements IViewport { private _lastRecordedBufferHeight: number = 0; private _lastTouchY: number = 0; private _lastScrollTop: number = 0; + private _lastHadScrollBar: boolean = false; // Stores a partial line amount when scrolling, this is used to keep track of how much of a line // is scrolled so we can "scroll" over partial lines and feel natural on touchpads. This is a @@ -47,6 +48,7 @@ export class Viewport extends Disposable implements IViewport { // Unfortunately the overlay scrollbar would be hidden underneath the screen element in that case, // therefore we account for a standard amount to make it visible this.scrollBarWidth = (this._viewportElement.offsetWidth - this._scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH; + this._lastHadScrollBar = true; this.register(addDisposableDomListener(this._viewportElement, 'scroll', this._onScroll.bind(this))); // Perform this async to ensure the ICharSizeService is ready. @@ -93,14 +95,19 @@ export class Viewport extends Disposable implements IViewport { this._ignoreNextScrollEvent = true; this._viewportElement.scrollTop = scrollTop; } - if (this._optionsService.getOption('scrollback') === 0) { + + // Update scroll bar width + if (this._optionsService.options.scrollback === 0) { this.scrollBarWidth = 0; } else { this.scrollBarWidth = (this._viewportElement.offsetWidth - this._scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH; } + this._lastHadScrollBar = this.scrollBarWidth > 0; + this._viewportElement.style.width = (this._renderService.dimensions.actualCellWidth * (this._bufferService.cols) + this.scrollBarWidth).toString() + 'px'; this._refreshAnimationFrame = null; } + /** * Updates dimensions and synchronizes the scroll area if necessary. */ @@ -136,9 +143,11 @@ export class Viewport extends Disposable implements IViewport { this._refresh(immediate); return; } - // This is for refreshing the viewport if scrollBarWidth has to be updated - this._refresh(immediate); - return; + + // If the scroll bar visibility changed + if (this._lastHadScrollBar !== (this._optionsService.options.scrollback > 0)) { + this._refresh(immediate); + } } /** From b19b3f0fb693518246268669b8533eada8ed337a Mon Sep 17 00:00:00 2001 From: Simran Narang Date: Tue, 31 Aug 2021 11:41:00 +0530 Subject: [PATCH 129/164] Implemented all the changes requested! All Suggested changes committed successfully! --- demo/index.html | 37 +++++++++++++++++++++++++++++-------- demo/style.css | 2 +- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/demo/index.html b/demo/index.html index 621a1883b..20924b66f 100644 --- a/demo/index.html +++ b/demo/index.html @@ -21,9 +21,10 @@
- - - + + + +

Options

@@ -36,7 +37,7 @@

Addons Control

SearchAddon

-

+

@@ -57,13 +58,32 @@

+
+

Test

+
+ + +
+
-
- - diff --git a/demo/style.css b/demo/style.css index 29c4cbb1c..cebd08e01 100644 --- a/demo/style.css +++ b/demo/style.css @@ -87,6 +87,6 @@ pre { padding: 6px 12px; border: 1px solid #ccc; border-top: none; - max-height: 67.7vh; + max-height: 100vh; overflow-y: auto; } From 9e40614b5cc1d64998014507b206b15895d2eaf9 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Tue, 31 Aug 2021 12:50:54 +0200 Subject: [PATCH 130/164] feat(test): use common function to launch the browser --- addons/xterm-addon-attach/test/AttachAddon.api.ts | 7 ++----- addons/xterm-addon-fit/test/FitAddon.api.ts | 7 ++----- addons/xterm-addon-search/test/SearchAddon.api.ts | 7 ++----- .../test/SerializeAddon.api.ts | 7 ++----- .../test/Unicode11Addon.api.ts | 7 ++----- .../test/WebLinksAddon.api.ts | 7 ++----- addons/xterm-addon-webgl/test/WebglRenderer.api.ts | 7 ++----- bin/test_api.js | 6 ++++++ test/api/CharWidth.api.ts | 7 ++----- test/api/InputHandler.api.ts | 6 ++---- test/api/MouseTracking.api.ts | 6 ++---- test/api/Parser.api.ts | 7 ++----- test/api/Terminal.api.ts | 7 ++----- test/api/TestUtils.ts | 14 ++++++++++++++ 14 files changed, 44 insertions(+), 58 deletions(-) diff --git a/addons/xterm-addon-attach/test/AttachAddon.api.ts b/addons/xterm-addon-attach/test/AttachAddon.api.ts index ef26cfd23..8335cf0f3 100644 --- a/addons/xterm-addon-attach/test/AttachAddon.api.ts +++ b/addons/xterm-addon-attach/test/AttachAddon.api.ts @@ -4,7 +4,7 @@ */ import WebSocket = require('ws'); -import { openTerminal, pollFor, getBrowserType } from '../../../out-test/api/TestUtils'; +import { openTerminal, pollFor, launchBrowser } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; const APP = 'http://127.0.0.1:3001/test'; @@ -16,10 +16,7 @@ const height = 600; describe('AttachAddon', () => { before(async function(): Promise { - const browserType = getBrowserType(); - browser = await browserType.launch({ - headless: process.argv.includes('--headless') - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); }); diff --git a/addons/xterm-addon-fit/test/FitAddon.api.ts b/addons/xterm-addon-fit/test/FitAddon.api.ts index 8859b5a66..987092adc 100644 --- a/addons/xterm-addon-fit/test/FitAddon.api.ts +++ b/addons/xterm-addon-fit/test/FitAddon.api.ts @@ -4,7 +4,7 @@ */ import { assert } from 'chai'; -import { openTerminal, getBrowserType } from '../../../out-test/api/TestUtils'; +import { openTerminal, launchBrowser } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; const APP = 'http://127.0.0.1:3001/test'; @@ -16,10 +16,7 @@ const height = 768; describe('FitAddon', () => { before(async function(): Promise { - const browserType = getBrowserType(); - browser = await browserType.launch({ - headless: process.argv.includes('--headless') - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); await page.goto(APP); diff --git a/addons/xterm-addon-search/test/SearchAddon.api.ts b/addons/xterm-addon-search/test/SearchAddon.api.ts index 3c94d416b..8bdf61cf1 100644 --- a/addons/xterm-addon-search/test/SearchAddon.api.ts +++ b/addons/xterm-addon-search/test/SearchAddon.api.ts @@ -6,7 +6,7 @@ import { assert } from 'chai'; import { readFile } from 'fs'; import { resolve } from 'path'; -import { openTerminal, writeSync, getBrowserType } from '../../../out-test/api/TestUtils'; +import { openTerminal, writeSync, launchBrowser } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; const APP = 'http://127.0.0.1:3001/test'; @@ -18,10 +18,7 @@ const height = 600; describe('Search Tests', function(): void { before(async function(): Promise { - const browserType = getBrowserType(); - browser = await browserType.launch({ - headless: process.argv.includes('--headless') - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); await page.goto(APP); diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index 87f77f596..bb66f37b2 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -4,7 +4,7 @@ */ import { assert } from 'chai'; -import { openTerminal, writeSync, getBrowserType } from '../../../out-test/api/TestUtils'; +import { openTerminal, writeSync, launchBrowser } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; const APP = 'http://127.0.0.1:3001/test'; @@ -38,10 +38,7 @@ async function testSerializeEquals(writeContent: string, expectedSerialized: str describe('SerializeAddon', () => { before(async function(): Promise { - const browserType = getBrowserType(); - browser = await browserType.launch({ - headless: process.argv.includes('--headless') - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); await page.goto(APP); diff --git a/addons/xterm-addon-unicode11/test/Unicode11Addon.api.ts b/addons/xterm-addon-unicode11/test/Unicode11Addon.api.ts index ba536e904..4c695b001 100644 --- a/addons/xterm-addon-unicode11/test/Unicode11Addon.api.ts +++ b/addons/xterm-addon-unicode11/test/Unicode11Addon.api.ts @@ -4,7 +4,7 @@ */ import { assert } from 'chai'; -import { openTerminal, getBrowserType } from '../../../out-test/api/TestUtils'; +import { openTerminal, launchBrowser } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; const APP = 'http://127.0.0.1:3001/test'; @@ -16,10 +16,7 @@ const height = 600; describe('Unicode11Addon', () => { before(async function(): Promise { - const browserType = getBrowserType(); - browser = await browserType.launch({ - headless: process.argv.includes('--headless') - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); }); diff --git a/addons/xterm-addon-web-links/test/WebLinksAddon.api.ts b/addons/xterm-addon-web-links/test/WebLinksAddon.api.ts index 54650f1f9..fe44dc31e 100644 --- a/addons/xterm-addon-web-links/test/WebLinksAddon.api.ts +++ b/addons/xterm-addon-web-links/test/WebLinksAddon.api.ts @@ -4,7 +4,7 @@ */ import { assert } from 'chai'; -import { openTerminal, pollFor, writeSync, getBrowserType } from '../../../out-test/api/TestUtils'; +import { openTerminal, pollFor, writeSync, launchBrowser } from '../../../out-test/api/TestUtils'; import { Browser, Page } from 'playwright'; const APP = 'http://127.0.0.1:3001/test'; @@ -16,10 +16,7 @@ const height = 600; describe('WebLinksAddon', () => { before(async function(): Promise { - const browserType = getBrowserType(); - browser = await browserType.launch({ - headless: process.argv.includes('--headless') - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); }); diff --git a/addons/xterm-addon-webgl/test/WebglRenderer.api.ts b/addons/xterm-addon-webgl/test/WebglRenderer.api.ts index 793929e93..e6942d1cb 100644 --- a/addons/xterm-addon-webgl/test/WebglRenderer.api.ts +++ b/addons/xterm-addon-webgl/test/WebglRenderer.api.ts @@ -6,7 +6,7 @@ import { assert } from 'chai'; import { Browser, Page } from 'playwright'; import { ITheme } from 'xterm'; -import { getBrowserType, openTerminal, pollFor, writeSync } from '../../../out-test/api/TestUtils'; +import { getBrowserType, launchBrowser, openTerminal, pollFor, writeSync } from '../../../out-test/api/TestUtils'; import { ITerminalOptions } from '../../../src/common/Types'; const APP = 'http://127.0.0.1:3001/test'; @@ -905,10 +905,7 @@ async function getCellPixels(col: number, row: number): Promise { } async function setupBrowser(options: ITerminalOptions = { rendererType: 'dom' }): Promise { - const browserType = getBrowserType(); - browser = await browserType.launch({ - headless: process.argv.includes('--headless') - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); await page.goto(APP); diff --git a/bin/test_api.js b/bin/test_api.js index 9fe4659a8..f173b4175 100644 --- a/bin/test_api.js +++ b/bin/test_api.js @@ -59,6 +59,12 @@ server.stdout.on('data', (data) => { `${script}.cmd` : script)); } + server.kill(); + process.exit(run.status); } }); + +server.stderr.on('data', (data) => { + console.error(data.toString()); +}); diff --git a/test/api/CharWidth.api.ts b/test/api/CharWidth.api.ts index d7cea109e..83067149a 100644 --- a/test/api/CharWidth.api.ts +++ b/test/api/CharWidth.api.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { pollFor, openTerminal, getBrowserType } from './TestUtils'; +import { pollFor, openTerminal, launchBrowser } from './TestUtils'; import { Browser, Page } from 'playwright'; const APP = 'http://127.0.0.1:3001/test'; @@ -15,10 +15,7 @@ const height = 600; describe('CharWidth Integration Tests', function(): void { before(async function(): Promise { - const browserType = getBrowserType(); - browser = await browserType.launch({ - headless: process.argv.indexOf('--headless') !== -1 - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); await page.goto(APP); diff --git a/test/api/InputHandler.api.ts b/test/api/InputHandler.api.ts index a695abdce..54ee69571 100644 --- a/test/api/InputHandler.api.ts +++ b/test/api/InputHandler.api.ts @@ -4,7 +4,7 @@ */ import { assert } from 'chai'; -import { pollFor, openTerminal, getBrowserType } from './TestUtils'; +import { pollFor, openTerminal, getBrowserType, launchBrowser } from './TestUtils'; import { Browser, Page } from 'playwright'; import { IRenderDimensions } from 'browser/renderer/Types'; @@ -21,9 +21,7 @@ describe('InputHandler Integration Tests', function(): void { before(async function(): Promise { const browserType = getBrowserType(); isChromium = browserType.name() === 'chromium'; - browser = await browserType.launch({ - headless: process.argv.indexOf('--headless') !== -1 - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); await page.goto(APP); diff --git a/test/api/MouseTracking.api.ts b/test/api/MouseTracking.api.ts index 3df21a901..ebeb680f4 100644 --- a/test/api/MouseTracking.api.ts +++ b/test/api/MouseTracking.api.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { pollFor, writeSync, openTerminal, getBrowserType } from './TestUtils'; +import { pollFor, writeSync, openTerminal, getBrowserType, launchBrowser } from './TestUtils'; import { Browser, Page } from 'playwright'; const APP = 'http://127.0.0.1:3001/test'; @@ -211,9 +211,7 @@ describe('Mouse Tracking Tests', async () => { const itMouse = isChromium ? it : it.skip; before(async function(): Promise { - browser = await browserType.launch({ - headless: process.argv.indexOf('--headless') !== -1 - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); }); diff --git a/test/api/Parser.api.ts b/test/api/Parser.api.ts index 0ef57cf17..ada28adfa 100644 --- a/test/api/Parser.api.ts +++ b/test/api/Parser.api.ts @@ -4,7 +4,7 @@ */ import { assert } from 'chai'; -import { writeSync, openTerminal, getBrowserType } from './TestUtils'; +import { writeSync, openTerminal, launchBrowser } from './TestUtils'; import { Browser, Page } from 'playwright'; const APP = 'http://127.0.0.1:3001/test'; @@ -16,10 +16,7 @@ const height = 600; describe('Parser Integration Tests', function (): void { before(async function (): Promise { - const browserType = getBrowserType(); - browser = await browserType.launch({ - headless: process.argv.indexOf('--headless') !== -1 - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); await page.goto(APP); diff --git a/test/api/Terminal.api.ts b/test/api/Terminal.api.ts index 1599f3a21..00598e478 100644 --- a/test/api/Terminal.api.ts +++ b/test/api/Terminal.api.ts @@ -4,7 +4,7 @@ */ import { assert } from 'chai'; -import { pollFor, timeout, writeSync, openTerminal, getBrowserType } from './TestUtils'; +import { pollFor, timeout, writeSync, openTerminal, launchBrowser } from './TestUtils'; import { Browser, Page } from 'playwright'; const APP = 'http://127.0.0.1:3001/test'; @@ -16,10 +16,7 @@ const height = 600; describe('API Integration Tests', function(): void { before(async () => { - const browserType = getBrowserType(); - browser = await browserType.launch({ - headless: process.argv.indexOf('--headless') !== -1 - }); + browser = await launchBrowser(); page = await (await browser.newContext()).newPage(); await page.setViewportSize({ width, height }); }); diff --git a/test/api/TestUtils.ts b/test/api/TestUtils.ts index 2b1e88284..4fa98d438 100644 --- a/test/api/TestUtils.ts +++ b/test/api/TestUtils.ts @@ -67,3 +67,17 @@ export function getBrowserType(): playwright.BrowserType = { + headless: process.argv.includes('--headless'), + } + + const index = process.argv.indexOf('--executablePath'); + if(index > 0 && process.argv.length > index + 1 && typeof process.argv[index + 1] === 'string') { + options.executablePath = process.argv[index + 1]; + } + + return browserType.launch(options); +} From 50e8727111c0e8dcf88228d58e8ab92d11b7d106 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Tue, 31 Aug 2021 13:04:40 +0200 Subject: [PATCH 131/164] refactor(test): add command to run an unique test and support Mocha Explorer extension --- .mocharc.yml | 11 +++++++++++ .vscode/settings.json | 5 ++++- package.json | 2 ++ yarn.lock | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .mocharc.yml diff --git a/.mocharc.yml b/.mocharc.yml new file mode 100644 index 000000000..c19fe15ab --- /dev/null +++ b/.mocharc.yml @@ -0,0 +1,11 @@ +require: + - source-map-support/register +spec: + - out/**/*.test.js + - addons/**/out/*.test.js +watch-files: + - out/**/*.js + - addons/**/out/*.js +reporter: spec +color: true +check-leaks: true diff --git a/.vscode/settings.json b/.vscode/settings.json index f07ca5457..ecea784cd 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,7 @@ { "typescript.preferences.importModuleSpecifier": "non-relative", - "typescript.preferences.quoteStyle": "single" + "typescript.preferences.quoteStyle": "single", + "mochaExplorer.env": { + "NODE_PATH": "./out" + } } diff --git a/package.json b/package.json index 71a0f3080..40de4017c 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "test-api-webkit": "node ./bin/test_api.js --browser=webkit --timeout=20000", "test-unit": "node ./bin/test.js", "test-unit-coverage": "node ./bin/test.js --coverage", + "test:dev": "NODE_PATH='./out' mocha", "build": "tsc -b ./tsconfig.all.json", "prepare": "npm run setup", "setup": "npm run build", @@ -61,6 +62,7 @@ "nyc": "^15.1.0", "playwright": "^1.11.0", "source-map-loader": "^2.0.1", + "source-map-support": "^0.5.19", "ts-loader": "^9.1.2", "typescript": "^4.2.4", "utf8": "^3.0.0", diff --git a/yarn.lock b/yarn.lock index 571f8a90f..0d8ac14ff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3909,7 +3909,7 @@ source-map-loader@^2.0.1: iconv-lite "^0.6.2" source-map-js "^0.6.2" -source-map-support@~0.5.19: +source-map-support@^0.5.19, source-map-support@~0.5.19: version "0.5.19" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== From 8801926b1000c89bb1d50b4f1684e182140f0dd1 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Tue, 31 Aug 2021 15:40:35 +0200 Subject: [PATCH 132/164] fix: `test:dev` is running on Windows --- package.json | 3 ++- yarn.lock | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 40de4017c..43fb640e2 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "test-api-webkit": "node ./bin/test_api.js --browser=webkit --timeout=20000", "test-unit": "node ./bin/test.js", "test-unit-coverage": "node ./bin/test.js --coverage", - "test:dev": "NODE_PATH='./out' mocha", + "test:dev": "cross-env NODE_PATH='./out' mocha", "build": "tsc -b ./tsconfig.all.json", "prepare": "npm run setup", "setup": "npm run build", @@ -50,6 +50,7 @@ "@typescript-eslint/eslint-plugin": "^4.23.0", "@typescript-eslint/parser": "^4.23.0", "chai": "^4.3.4", + "cross-env": "^7.0.3", "deep-equal": "^2.0.5", "eslint": "^7.26.0", "express": "^4.17.1", diff --git a/yarn.lock b/yarn.lock index 0d8ac14ff..cf92d8f7a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1329,7 +1329,14 @@ core-util-is@1.0.2, core-util-is@~1.0.0: resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= -cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: +cross-env@^7.0.3: + version "7.0.3" + resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf" + integrity sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw== + dependencies: + cross-spawn "^7.0.1" + +cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== From 7cda0017aa0f14d6e7ab8677e28f7a58ff2b89f5 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Tue, 31 Aug 2021 15:53:43 +0200 Subject: [PATCH 133/164] fix: make Mocha Explorer working on Windows --- .env.test | 1 + .vscode/settings.json | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) create mode 100644 .env.test diff --git a/.env.test b/.env.test new file mode 100644 index 000000000..78a9f9302 --- /dev/null +++ b/.env.test @@ -0,0 +1 @@ +NODE_PATH=./out diff --git a/.vscode/settings.json b/.vscode/settings.json index ecea784cd..7720b1ee7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,5 @@ { "typescript.preferences.importModuleSpecifier": "non-relative", "typescript.preferences.quoteStyle": "single", - "mochaExplorer.env": { - "NODE_PATH": "./out" - } + "mochaExplorer.envPath": ".env.test" } From 8edf0d5e1dcd0d68dc2ec815ffc22bc0350e0c72 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 31 Aug 2021 07:29:31 -0700 Subject: [PATCH 134/164] Improve checkbox and italics styling --- demo/index.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/demo/index.html b/demo/index.html index 20924b66f..fc5ca1757 100644 --- a/demo/index.html +++ b/demo/index.html @@ -37,19 +37,19 @@

Addons Control

SearchAddon

-

+

- - - -

+ + + +

SerializeAddon

-

+

-

+

Style

From f12b917930da17a5894965e0239cd140c871a2f3 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 31 Aug 2021 07:32:54 -0700 Subject: [PATCH 135/164] Make addons tab title consistent --- demo/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/index.html b/demo/index.html index fc5ca1757..33389ae9f 100644 --- a/demo/index.html +++ b/demo/index.html @@ -22,7 +22,7 @@
- +
From ac750596840ad3d43d788eb956ac48911abae623 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Tue, 31 Aug 2021 16:56:40 +0200 Subject: [PATCH 136/164] refactor: rename file to a better name --- .env.test => .mocha.env | 0 .vscode/settings.json | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename .env.test => .mocha.env (100%) diff --git a/.env.test b/.mocha.env similarity index 100% rename from .env.test rename to .mocha.env diff --git a/.vscode/settings.json b/.vscode/settings.json index 7720b1ee7..9fa94d5f7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { "typescript.preferences.importModuleSpecifier": "non-relative", "typescript.preferences.quoteStyle": "single", - "mochaExplorer.envPath": ".env.test" + "mochaExplorer.envPath": ".mocha.env" } From f41eea025ec68948ce1a92d1010ec2e3fce4c76f Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Tue, 31 Aug 2021 16:58:20 +0200 Subject: [PATCH 137/164] refactor: rename script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 43fb640e2..29b6fd46f 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "test-api-webkit": "node ./bin/test_api.js --browser=webkit --timeout=20000", "test-unit": "node ./bin/test.js", "test-unit-coverage": "node ./bin/test.js --coverage", - "test:dev": "cross-env NODE_PATH='./out' mocha", + "test-unit-dev": "cross-env NODE_PATH='./out' mocha", "build": "tsc -b ./tsconfig.all.json", "prepare": "npm run setup", "setup": "npm run build", From b3c0c2bd3c9e1c7c009129ebd43d47eca279f280 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 1 Sep 2021 05:45:00 -0700 Subject: [PATCH 138/164] Add loadtest button to demo --- demo/client.ts | 34 ++++++++++++++++++++++++++++++++++ demo/index.html | 1 + 2 files changed, 35 insertions(+) diff --git a/demo/client.ts b/demo/client.ts index 48b6d1779..a02b155ca 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -148,6 +148,7 @@ if (document.location.pathname === '/test') { document.getElementById('dispose').addEventListener('click', disposeRecreateButtonHandler); document.getElementById('serialize').addEventListener('click', serializeButtonHandler); document.getElementById('custom-glyph').addEventListener('click', writeCustomGlyphHandler); + document.getElementById('load-test').addEventListener('click', loadTest); } function createTerminal(): void { @@ -481,3 +482,36 @@ function writeCustomGlyphHandler() { term.write(' ╚══╩══╝ └──┴──┘ ╰──┴──╯ ╰──┴──╯ ┗━━┻━━┛ └╌╌┘ ╎ ┗╍╍┛ ┋ ▁▂▃▄▅▆▇█\n\r'); window.scrollTo(0, 0); } + +function loadTest() { + const isWebglEnabled = !!addons.webgl.instance; + const testData = []; + let byteCount = 0; + for (let i = 0; i < 50; i++) { + const count = 1 + Math.floor(Math.random() * 79); + byteCount += count + 2; + const data = new Uint8Array(count + 2); + data[0] = 0x0A; // \n + for (let i = 1; i < count + 1; i++) { + data[i] = 0x61 + Math.floor(Math.random() * (0x7A - 0x61)); + } + // End each line with \r so the cursor remains constant, this is what ls/tree do and improves + // performance significantly due to the cursor DOM element not needing to change + data[data.length - 1] = 0x0D; // \r + testData.push(data); + } + const start = performance.now(); + for (let i = 0; i < 1024; i++) { + for (const d of testData) { + term.write(d); + } + } + // Wait for all data to be parsed before evaluating time + term.write('', () => { + const time = Math.round(performance.now() - start); + const mbs = ((byteCount / 1024) * (1 / (time / 1000))).toFixed(2); + term.write(`\n\r\nWrote ${byteCount}kB in ${time}ms (${mbs}MB/s) using the (${isWebglEnabled ? 'webgl' : 'canvas'} renderer)`); + // Send ^C to get a new prompt + term._core._onData.fire('\x03'); + }); +} diff --git a/demo/index.html b/demo/index.html index 33389ae9f..9c86783b5 100644 --- a/demo/index.html +++ b/demo/index.html @@ -63,6 +63,7 @@
+
From cece3db0cb01bfb403d468010b89fb3161fe0b5d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 1 Sep 2021 06:15:59 -0700 Subject: [PATCH 139/164] Cache a copy of the active buffer as a private prop This reduces GC from the const buffer workaround that avoids excessive getter access with far less getter access Part of #3450 --- src/common/InputHandler.ts | 435 ++++++++++++++++++------------------- 1 file changed, 206 insertions(+), 229 deletions(-) diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index d4354e90a..f2f0d0ce4 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -20,6 +20,7 @@ import { AttributeData } from 'common/buffer/AttributeData'; import { ICoreService, IBufferService, IOptionsService, ILogService, IDirtyRowService, ICoreMouseService, ICharsetService, IUnicodeService, LogLevelEnum } from 'common/services/Services'; import { OscHandler } from 'common/parser/OscParser'; import { DcsHandler } from 'common/parser/DcsParser'; +import { IBuffer } from 'common/buffer/Types'; /** * Map collect to glevel. Used in `selectCharset`. @@ -234,6 +235,8 @@ export class InputHandler extends Disposable implements IInputHandler { private _curAttrData: IAttributeData = DEFAULT_ATTR_DATA.clone(); private _eraseAttrDataInternal: IAttributeData = DEFAULT_ATTR_DATA.clone(); + private _activeBuffer: IBuffer; + private _onRequestBell = new EventEmitter(); public get onRequestBell(): IEvent { return this._onRequestBell.event; } private _onRequestRefreshRows = new EventEmitter(); @@ -282,6 +285,10 @@ export class InputHandler extends Disposable implements IInputHandler { super(); this.register(this._parser); + // Track properties used in performance critical code manually to avoid using slow getters + this._activeBuffer = this._bufferService.buffer; + this.register(this._bufferService.buffers.onBufferActivate(e => this._activeBuffer = e.activeBuffer)); + /** * custom fallback handlers */ @@ -508,9 +515,8 @@ export class InputHandler extends Disposable implements IInputHandler { */ public parse(data: string | Uint8Array, promiseResult?: boolean): void | Promise { let result: void | Promise; - let buffer = this._bufferService.buffer; - let cursorStartX = buffer.x; - let cursorStartY = buffer.y; + let cursorStartX = this._activeBuffer.x; + let cursorStartY = this._activeBuffer.y; let start = 0; const wasPaused = this._parseStack.paused; @@ -569,8 +575,7 @@ export class InputHandler extends Disposable implements IInputHandler { } } - buffer = this._bufferService.buffer; - if (buffer.x !== cursorStartX || buffer.y !== cursorStartY) { + if (this._activeBuffer.x !== cursorStartX || this._activeBuffer.y !== cursorStartY) { this._onCursorMove.fire(); } @@ -581,20 +586,19 @@ export class InputHandler extends Disposable implements IInputHandler { public print(data: Uint32Array, start: number, end: number): void { let code: number; let chWidth: number; - const buffer = this._bufferService.buffer; const charset = this._charsetService.charset; const screenReaderMode = this._optionsService.options.screenReaderMode; const cols = this._bufferService.cols; const wraparoundMode = this._coreService.decPrivateModes.wraparound; const insertMode = this._coreService.modes.insertMode; const curAttr = this._curAttrData; - let bufferRow = buffer.lines.get(buffer.ybase + buffer.y)!; + let bufferRow = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y)!; - this._dirtyRowService.markDirty(buffer.y); + this._dirtyRowService.markDirty(this._activeBuffer.y); // handle wide chars: reset start_cell-1 if we would overwrite the second cell of a wide char - if (buffer.x && end - start > 0 && bufferRow.getWidth(buffer.x - 1) === 2) { - bufferRow.setCellFromCodePoint(buffer.x - 1, 0, 1, curAttr.fg, curAttr.bg, curAttr.extended); + if (this._activeBuffer.x && end - start > 0 && bufferRow.getWidth(this._activeBuffer.x - 1) === 2) { + bufferRow.setCellFromCodePoint(this._activeBuffer.x - 1, 0, 1, curAttr.fg, curAttr.bg, curAttr.extended); } for (let pos = start; pos < end; ++pos) { @@ -619,17 +623,17 @@ export class InputHandler extends Disposable implements IInputHandler { } // insert combining char at last cursor position - // buffer.x should never be 0 for a combining char + // this._activeBuffer.x should never be 0 for a combining char // since they always follow a cell consuming char - // therefore we can test for buffer.x to avoid overflow left - if (!chWidth && buffer.x) { - if (!bufferRow.getWidth(buffer.x - 1)) { + // therefore we can test for this._activeBuffer.x to avoid overflow left + if (!chWidth && this._activeBuffer.x) { + if (!bufferRow.getWidth(this._activeBuffer.x - 1)) { // found empty cell after fullwidth, need to go 2 cells back // it is save to step 2 cells back here // since an empty cell is only set by fullwidth chars - bufferRow.addCodepointToCell(buffer.x - 2, code); + bufferRow.addCodepointToCell(this._activeBuffer.x - 2, code); } else { - bufferRow.addCodepointToCell(buffer.x - 1, code); + bufferRow.addCodepointToCell(this._activeBuffer.x - 1, code); } continue; } @@ -637,31 +641,31 @@ export class InputHandler extends Disposable implements IInputHandler { // goto next line if ch would overflow // NOTE: To avoid costly width checks here, // the terminal does not allow a cols < 2. - if (buffer.x + chWidth - 1 >= cols) { + if (this._activeBuffer.x + chWidth - 1 >= cols) { // autowrap - DECAWM // automatically wraps to the beginning of the next line if (wraparoundMode) { // clear left over cells to the right - while (buffer.x < cols) { - bufferRow.setCellFromCodePoint(buffer.x++, 0, 1, curAttr.fg, curAttr.bg, curAttr.extended); + while (this._activeBuffer.x < cols) { + bufferRow.setCellFromCodePoint(this._activeBuffer.x++, 0, 1, curAttr.fg, curAttr.bg, curAttr.extended); } - buffer.x = 0; - buffer.y++; - if (buffer.y === buffer.scrollBottom + 1) { - buffer.y--; + this._activeBuffer.x = 0; + this._activeBuffer.y++; + if (this._activeBuffer.y === this._activeBuffer.scrollBottom + 1) { + this._activeBuffer.y--; this._bufferService.scroll(this._eraseAttrData(), true); } else { - if (buffer.y >= this._bufferService.rows) { - buffer.y = this._bufferService.rows - 1; + if (this._activeBuffer.y >= this._bufferService.rows) { + this._activeBuffer.y = this._bufferService.rows - 1; } // The line already exists (eg. the initial viewport), mark it as a // wrapped line - buffer.lines.get(buffer.ybase + buffer.y)!.isWrapped = true; + this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y)!.isWrapped = true; } // row changed, get it again - bufferRow = buffer.lines.get(buffer.ybase + buffer.y)!; + bufferRow = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y)!; } else { - buffer.x = cols - 1; + this._activeBuffer.x = cols - 1; if (chWidth === 2) { // FIXME: check for xterm behavior // What to do here? We got a wide char that does not fit into last cell @@ -673,7 +677,7 @@ export class InputHandler extends Disposable implements IInputHandler { // insert mode: move characters to right if (insertMode) { // right shift cells according to the width - bufferRow.insertCells(buffer.x, chWidth, buffer.getNullCell(curAttr), curAttr); + bufferRow.insertCells(this._activeBuffer.x, chWidth, this._activeBuffer.getNullCell(curAttr), curAttr); // test last cell - since the last cell has only room for // a halfwidth char any fullwidth shifted there is lost // and will be set to empty cell @@ -683,15 +687,15 @@ export class InputHandler extends Disposable implements IInputHandler { } // write current char to buffer and advance cursor - bufferRow.setCellFromCodePoint(buffer.x++, code, chWidth, curAttr.fg, curAttr.bg, curAttr.extended); + bufferRow.setCellFromCodePoint(this._activeBuffer.x++, code, chWidth, curAttr.fg, curAttr.bg, curAttr.extended); // fullwidth char - also set next cell to placeholder stub and advance cursor // for graphemes bigger than fullwidth we can simply loop to zero - // we already made sure above, that buffer.x + chWidth will not overflow right + // we already made sure above, that this._activeBuffer.x + chWidth will not overflow right if (chWidth > 0) { while (--chWidth) { // other than a regular empty cell a cell following a wide char has no width - bufferRow.setCellFromCodePoint(buffer.x++, 0, 0, curAttr.fg, curAttr.bg, curAttr.extended); + bufferRow.setCellFromCodePoint(this._activeBuffer.x++, 0, 0, curAttr.fg, curAttr.bg, curAttr.extended); } } } @@ -700,7 +704,7 @@ export class InputHandler extends Disposable implements IInputHandler { // - fullwidth + surrogates: reset // - combining: only base char gets carried on (bug in xterm?) if (end - start > 0) { - bufferRow.loadCell(buffer.x - 1, this._workCell); + bufferRow.loadCell(this._activeBuffer.x - 1, this._workCell); if (this._workCell.getWidth() === 2 || this._workCell.getCode() > 0xFFFF) { this._parser.precedingCodepoint = 0; } else if (this._workCell.isCombined()) { @@ -711,11 +715,11 @@ export class InputHandler extends Disposable implements IInputHandler { } // handle wide chars: reset cell to the right if it is second cell of a wide char - if (buffer.x < cols && end - start > 0 && bufferRow.getWidth(buffer.x) === 0 && !bufferRow.hasContent(buffer.x)) { - bufferRow.setCellFromCodePoint(buffer.x, 0, 1, curAttr.fg, curAttr.bg, curAttr.extended); + if (this._activeBuffer.x < cols && end - start > 0 && bufferRow.getWidth(this._activeBuffer.x) === 0 && !bufferRow.hasContent(this._activeBuffer.x)) { + bufferRow.setCellFromCodePoint(this._activeBuffer.x, 0, 1, curAttr.fg, curAttr.bg, curAttr.extended); } - this._dirtyRowService.markDirty(buffer.y); + this._dirtyRowService.markDirty(this._activeBuffer.y); } /** @@ -779,25 +783,22 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y C0 FF "Form Feed" "\f, \x0C" "Treated as LF." */ public lineFeed(): boolean { - // make buffer local for faster access - const buffer = this._bufferService.buffer; - - this._dirtyRowService.markDirty(buffer.y); + this._dirtyRowService.markDirty(this._activeBuffer.y); if (this._optionsService.options.convertEol) { - buffer.x = 0; + this._activeBuffer.x = 0; } - buffer.y++; - if (buffer.y === buffer.scrollBottom + 1) { - buffer.y--; + this._activeBuffer.y++; + if (this._activeBuffer.y === this._activeBuffer.scrollBottom + 1) { + this._activeBuffer.y--; this._bufferService.scroll(this._eraseAttrData()); - } else if (buffer.y >= this._bufferService.rows) { - buffer.y = this._bufferService.rows - 1; + } else if (this._activeBuffer.y >= this._bufferService.rows) { + this._activeBuffer.y = this._bufferService.rows - 1; } // If the end of the line is hit, prevent this action from wrapping around to the next line. - if (buffer.x >= this._bufferService.cols) { - buffer.x--; + if (this._activeBuffer.x >= this._bufferService.cols) { + this._activeBuffer.x--; } - this._dirtyRowService.markDirty(buffer.y); + this._dirtyRowService.markDirty(this._activeBuffer.y); this._onLineFeed.fire(); return true; @@ -810,7 +811,7 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y C0 CR "Carriage Return" "\r, \x0D" "Move the cursor to the beginning of the row." */ public carriageReturn(): boolean { - this._bufferService.buffer.x = 0; + this._activeBuffer.x = 0; return true; } @@ -826,13 +827,11 @@ export class InputHandler extends Disposable implements IInputHandler { * with the cursor, thus at the home position (top-leftmost cell) this has no effect. */ public backspace(): boolean { - const buffer = this._bufferService.buffer; - // reverse wrap-around is disabled if (!this._coreService.decPrivateModes.reverseWraparound) { this._restrictCursor(); - if (buffer.x > 0) { - buffer.x--; + if (this._activeBuffer.x > 0) { + this._activeBuffer.x--; } return true; } @@ -842,8 +841,8 @@ export class InputHandler extends Disposable implements IInputHandler { // to be at x=cols to be able to address the last cell of a row by BS this._restrictCursor(this._bufferService.cols); - if (buffer.x > 0) { - buffer.x--; + if (this._activeBuffer.x > 0) { + this._activeBuffer.x--; } else { /** * reverse wrap-around handling: @@ -853,21 +852,21 @@ export class InputHandler extends Disposable implements IInputHandler { * - cannot peek into scrollbuffer * - any cursor movement sequence keeps working as expected */ - if (buffer.x === 0 - && buffer.y > buffer.scrollTop - && buffer.y <= buffer.scrollBottom - && buffer.lines.get(buffer.ybase + buffer.y)?.isWrapped) + if (this._activeBuffer.x === 0 + && this._activeBuffer.y > this._activeBuffer.scrollTop + && this._activeBuffer.y <= this._activeBuffer.scrollBottom + && this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y)?.isWrapped) { - buffer.lines.get(buffer.ybase + buffer.y)!.isWrapped = false; - buffer.y--; - buffer.x = this._bufferService.cols - 1; + this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y)!.isWrapped = false; + this._activeBuffer.y--; + this._activeBuffer.x = this._bufferService.cols - 1; // find last taken cell - last cell can have 3 different states: // - hasContent(true) + hasWidth(1): narrow char - we are done // - hasWidth(0): second part of wide char - we are done // - hasContent(false) + hasWidth(1): empty cell due to early wrapping wide char, go one cell further back - const line = buffer.lines.get(buffer.ybase + buffer.y)!; - if (line.hasWidth(buffer.x) && !line.hasContent(buffer.x)) { - buffer.x--; + const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y)!; + if (line.hasWidth(this._activeBuffer.x) && !line.hasContent(this._activeBuffer.x)) { + this._activeBuffer.x--; // We do this only once, since width=1 + hasContent=false currently happens only once before // early wrapping of a wide char. // This needs to be fixed once we support graphemes taking more than 2 cells. @@ -885,13 +884,13 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y C0 HT "Horizontal Tabulation" "\t, \x09" "Move the cursor to the next character tab stop." */ public tab(): boolean { - if (this._bufferService.buffer.x >= this._bufferService.cols) { + if (this._activeBuffer.x >= this._bufferService.cols) { return true; } - const originalX = this._bufferService.buffer.x; - this._bufferService.buffer.x = this._bufferService.buffer.nextStop(); + const originalX = this._activeBuffer.x; + this._activeBuffer.x = this._activeBuffer.nextStop(); if (this._optionsService.options.screenReaderMode) { - this._onA11yTab.fire(this._bufferService.buffer.x - originalX); + this._onA11yTab.fire(this._activeBuffer.x - originalX); } return true; } @@ -924,27 +923,27 @@ export class InputHandler extends Disposable implements IInputHandler { * Restrict cursor to viewport size / scroll margin (origin mode). */ private _restrictCursor(maxCol: number = this._bufferService.cols - 1): void { - this._bufferService.buffer.x = Math.min(maxCol, Math.max(0, this._bufferService.buffer.x)); - this._bufferService.buffer.y = this._coreService.decPrivateModes.origin - ? Math.min(this._bufferService.buffer.scrollBottom, Math.max(this._bufferService.buffer.scrollTop, this._bufferService.buffer.y)) - : Math.min(this._bufferService.rows - 1, Math.max(0, this._bufferService.buffer.y)); - this._dirtyRowService.markDirty(this._bufferService.buffer.y); + this._activeBuffer.x = Math.min(maxCol, Math.max(0, this._activeBuffer.x)); + this._activeBuffer.y = this._coreService.decPrivateModes.origin + ? Math.min(this._activeBuffer.scrollBottom, Math.max(this._activeBuffer.scrollTop, this._activeBuffer.y)) + : Math.min(this._bufferService.rows - 1, Math.max(0, this._activeBuffer.y)); + this._dirtyRowService.markDirty(this._activeBuffer.y); } /** * Set absolute cursor position. */ private _setCursor(x: number, y: number): void { - this._dirtyRowService.markDirty(this._bufferService.buffer.y); + this._dirtyRowService.markDirty(this._activeBuffer.y); if (this._coreService.decPrivateModes.origin) { - this._bufferService.buffer.x = x; - this._bufferService.buffer.y = this._bufferService.buffer.scrollTop + y; + this._activeBuffer.x = x; + this._activeBuffer.y = this._activeBuffer.scrollTop + y; } else { - this._bufferService.buffer.x = x; - this._bufferService.buffer.y = y; + this._activeBuffer.x = x; + this._activeBuffer.y = y; } this._restrictCursor(); - this._dirtyRowService.markDirty(this._bufferService.buffer.y); + this._dirtyRowService.markDirty(this._activeBuffer.y); } /** @@ -954,7 +953,7 @@ export class InputHandler extends Disposable implements IInputHandler { // for relative changes we have to make sure we are within 0 .. cols/rows - 1 // before calculating the new position this._restrictCursor(); - this._setCursor(this._bufferService.buffer.x + x, this._bufferService.buffer.y + y); + this._setCursor(this._activeBuffer.x + x, this._activeBuffer.y + y); } /** @@ -966,7 +965,7 @@ export class InputHandler extends Disposable implements IInputHandler { */ public cursorUp(params: IParams): boolean { // stop at scrollTop - const diffToTop = this._bufferService.buffer.y - this._bufferService.buffer.scrollTop; + const diffToTop = this._activeBuffer.y - this._activeBuffer.scrollTop; if (diffToTop >= 0) { this._moveCursor(0, -Math.min(diffToTop, params.params[0] || 1)); } else { @@ -984,7 +983,7 @@ export class InputHandler extends Disposable implements IInputHandler { */ public cursorDown(params: IParams): boolean { // stop at scrollBottom - const diffToBottom = this._bufferService.buffer.scrollBottom - this._bufferService.buffer.y; + const diffToBottom = this._activeBuffer.scrollBottom - this._activeBuffer.y; if (diffToBottom >= 0) { this._moveCursor(0, Math.min(diffToBottom, params.params[0] || 1)); } else { @@ -1025,7 +1024,7 @@ export class InputHandler extends Disposable implements IInputHandler { */ public cursorNextLine(params: IParams): boolean { this.cursorDown(params); - this._bufferService.buffer.x = 0; + this._activeBuffer.x = 0; return true; } @@ -1039,7 +1038,7 @@ export class InputHandler extends Disposable implements IInputHandler { */ public cursorPrecedingLine(params: IParams): boolean { this.cursorUp(params); - this._bufferService.buffer.x = 0; + this._activeBuffer.x = 0; return true; } @@ -1050,7 +1049,7 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y CSI CHA "Cursor Horizontal Absolute" "CSI Ps G" "Move cursor to `Ps`-th column of the active row (default=1)." */ public cursorCharAbsolute(params: IParams): boolean { - this._setCursor((params.params[0] || 1) - 1, this._bufferService.buffer.y); + this._setCursor((params.params[0] || 1) - 1, this._activeBuffer.y); return true; } @@ -1081,7 +1080,7 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y CSI HPA "Horizontal Position Absolute" "CSI Ps ` " "Same as CHA." */ public charPosAbsolute(params: IParams): boolean { - this._setCursor((params.params[0] || 1) - 1, this._bufferService.buffer.y); + this._setCursor((params.params[0] || 1) - 1, this._activeBuffer.y); return true; } @@ -1103,7 +1102,7 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y CSI VPA "Vertical Position Absolute" "CSI Ps d" "Move cursor to `Ps`-th row (default=1)." */ public linePosAbsolute(params: IParams): boolean { - this._setCursor(this._bufferService.buffer.x, (params.params[0] || 1) - 1); + this._setCursor(this._activeBuffer.x, (params.params[0] || 1) - 1); return true; } @@ -1146,9 +1145,9 @@ export class InputHandler extends Disposable implements IInputHandler { public tabClear(params: IParams): boolean { const param = params.params[0]; if (param === 0) { - delete this._bufferService.buffer.tabs[this._bufferService.buffer.x]; + delete this._activeBuffer.tabs[this._activeBuffer.x]; } else if (param === 3) { - this._bufferService.buffer.tabs = {}; + this._activeBuffer.tabs = {}; } return true; } @@ -1160,12 +1159,12 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y CSI CHT "Cursor Horizontal Tabulation" "CSI Ps I" "Move cursor `Ps` times tabs forward (default=1)." */ public cursorForwardTab(params: IParams): boolean { - if (this._bufferService.buffer.x >= this._bufferService.cols) { + if (this._activeBuffer.x >= this._bufferService.cols) { return true; } let param = params.params[0] || 1; while (param--) { - this._bufferService.buffer.x = this._bufferService.buffer.nextStop(); + this._activeBuffer.x = this._activeBuffer.nextStop(); } return true; } @@ -1176,16 +1175,13 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y CSI CBT "Cursor Backward Tabulation" "CSI Ps Z" "Move cursor `Ps` tabs backward (default=1)." */ public cursorBackwardTab(params: IParams): boolean { - if (this._bufferService.buffer.x >= this._bufferService.cols) { + if (this._activeBuffer.x >= this._bufferService.cols) { return true; } let param = params.params[0] || 1; - // make buffer local for faster access - const buffer = this._bufferService.buffer; - while (param--) { - buffer.x = buffer.prevStop(); + this._activeBuffer.x = this._activeBuffer.prevStop(); } return true; } @@ -1199,11 +1195,11 @@ export class InputHandler extends Disposable implements IInputHandler { * @param end end - 1 is last erased cell */ private _eraseInBufferLine(y: number, start: number, end: number, clearWrap: boolean = false): void { - const line = this._bufferService.buffer.lines.get(this._bufferService.buffer.ybase + y)!; + const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + y)!; line.replaceCells( start, end, - this._bufferService.buffer.getNullCell(this._eraseAttrData()), + this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData() ); if (clearWrap) { @@ -1217,8 +1213,8 @@ export class InputHandler extends Disposable implements IInputHandler { * @param y row index */ private _resetBufferLine(y: number): void { - const line = this._bufferService.buffer.lines.get(this._bufferService.buffer.ybase + y)!; - line.fill(this._bufferService.buffer.getNullCell(this._eraseAttrData())); + const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + y)!; + line.fill(this._activeBuffer.getNullCell(this._eraseAttrData())); line.isWrapped = false; } @@ -1251,22 +1247,22 @@ export class InputHandler extends Disposable implements IInputHandler { let j; switch (params.params[0]) { case 0: - j = this._bufferService.buffer.y; + j = this._activeBuffer.y; this._dirtyRowService.markDirty(j); - this._eraseInBufferLine(j++, this._bufferService.buffer.x, this._bufferService.cols, this._bufferService.buffer.x === 0); + this._eraseInBufferLine(j++, this._activeBuffer.x, this._bufferService.cols, this._activeBuffer.x === 0); for (; j < this._bufferService.rows; j++) { this._resetBufferLine(j); } this._dirtyRowService.markDirty(j); break; case 1: - j = this._bufferService.buffer.y; + j = this._activeBuffer.y; this._dirtyRowService.markDirty(j); // Deleted front part of line and everything before. This line will no longer be wrapped. - this._eraseInBufferLine(j, 0, this._bufferService.buffer.x + 1, true); - if (this._bufferService.buffer.x + 1 >= this._bufferService.cols) { + this._eraseInBufferLine(j, 0, this._activeBuffer.x + 1, true); + if (this._activeBuffer.x + 1 >= this._bufferService.cols) { // Deleted entire previous line. This next line can no longer be wrapped. - this._bufferService.buffer.lines.get(j + 1)!.isWrapped = false; + this._activeBuffer.lines.get(j + 1)!.isWrapped = false; } while (j--) { this._resetBufferLine(j); @@ -1283,11 +1279,11 @@ export class InputHandler extends Disposable implements IInputHandler { break; case 3: // Clear scrollback (everything not in viewport) - const scrollBackSize = this._bufferService.buffer.lines.length - this._bufferService.rows; + const scrollBackSize = this._activeBuffer.lines.length - this._bufferService.rows; if (scrollBackSize > 0) { - this._bufferService.buffer.lines.trimStart(scrollBackSize); - this._bufferService.buffer.ybase = Math.max(this._bufferService.buffer.ybase - scrollBackSize, 0); - this._bufferService.buffer.ydisp = Math.max(this._bufferService.buffer.ydisp - scrollBackSize, 0); + this._activeBuffer.lines.trimStart(scrollBackSize); + this._activeBuffer.ybase = Math.max(this._activeBuffer.ybase - scrollBackSize, 0); + this._activeBuffer.ydisp = Math.max(this._activeBuffer.ydisp - scrollBackSize, 0); // Force a scroll event to refresh viewport this._onScroll.fire(0); } @@ -1322,16 +1318,16 @@ export class InputHandler extends Disposable implements IInputHandler { this._restrictCursor(this._bufferService.cols); switch (params.params[0]) { case 0: - this._eraseInBufferLine(this._bufferService.buffer.y, this._bufferService.buffer.x, this._bufferService.cols); + this._eraseInBufferLine(this._activeBuffer.y, this._activeBuffer.x, this._bufferService.cols); break; case 1: - this._eraseInBufferLine(this._bufferService.buffer.y, 0, this._bufferService.buffer.x + 1); + this._eraseInBufferLine(this._activeBuffer.y, 0, this._activeBuffer.x + 1); break; case 2: - this._eraseInBufferLine(this._bufferService.buffer.y, 0, this._bufferService.cols); + this._eraseInBufferLine(this._activeBuffer.y, 0, this._bufferService.cols); break; } - this._dirtyRowService.markDirty(this._bufferService.buffer.y); + this._dirtyRowService.markDirty(this._activeBuffer.y); return true; } @@ -1348,26 +1344,23 @@ export class InputHandler extends Disposable implements IInputHandler { this._restrictCursor(); let param = params.params[0] || 1; - // make buffer local for faster access - const buffer = this._bufferService.buffer; - - if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) { + if (this._activeBuffer.y > this._activeBuffer.scrollBottom || this._activeBuffer.y < this._activeBuffer.scrollTop) { return true; } - const row: number = buffer.ybase + buffer.y; + const row: number = this._activeBuffer.ybase + this._activeBuffer.y; - const scrollBottomRowsOffset = this._bufferService.rows - 1 - buffer.scrollBottom; - const scrollBottomAbsolute = this._bufferService.rows - 1 + buffer.ybase - scrollBottomRowsOffset + 1; + const scrollBottomRowsOffset = this._bufferService.rows - 1 - this._activeBuffer.scrollBottom; + const scrollBottomAbsolute = this._bufferService.rows - 1 + this._activeBuffer.ybase - scrollBottomRowsOffset + 1; while (param--) { // test: echo -e '\e[44m\e[1L\e[0m' // blankLine(true) - xterm/linux behavior - buffer.lines.splice(scrollBottomAbsolute - 1, 1); - buffer.lines.splice(row, 0, buffer.getBlankLine(this._eraseAttrData())); + this._activeBuffer.lines.splice(scrollBottomAbsolute - 1, 1); + this._activeBuffer.lines.splice(row, 0, this._activeBuffer.getBlankLine(this._eraseAttrData())); } - this._dirtyRowService.markRangeDirty(buffer.y, buffer.scrollBottom); - buffer.x = 0; // see https://vt100.net/docs/vt220-rm/chapter4.html - vt220 only? + this._dirtyRowService.markRangeDirty(this._activeBuffer.y, this._activeBuffer.scrollBottom); + this._activeBuffer.x = 0; // see https://vt100.net/docs/vt220-rm/chapter4.html - vt220 only? return true; } @@ -1384,27 +1377,24 @@ export class InputHandler extends Disposable implements IInputHandler { this._restrictCursor(); let param = params.params[0] || 1; - // make buffer local for faster access - const buffer = this._bufferService.buffer; - - if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) { + if (this._activeBuffer.y > this._activeBuffer.scrollBottom || this._activeBuffer.y < this._activeBuffer.scrollTop) { return true; } - const row: number = buffer.ybase + buffer.y; + const row: number = this._activeBuffer.ybase + this._activeBuffer.y; let j: number; - j = this._bufferService.rows - 1 - buffer.scrollBottom; - j = this._bufferService.rows - 1 + buffer.ybase - j; + j = this._bufferService.rows - 1 - this._activeBuffer.scrollBottom; + j = this._bufferService.rows - 1 + this._activeBuffer.ybase - j; while (param--) { // test: echo -e '\e[44m\e[1M\e[0m' // blankLine(true) - xterm/linux behavior - buffer.lines.splice(row, 1); - buffer.lines.splice(j, 0, buffer.getBlankLine(this._eraseAttrData())); + this._activeBuffer.lines.splice(row, 1); + this._activeBuffer.lines.splice(j, 0, this._activeBuffer.getBlankLine(this._eraseAttrData())); } - this._dirtyRowService.markRangeDirty(buffer.y, buffer.scrollBottom); - buffer.x = 0; // see https://vt100.net/docs/vt220-rm/chapter4.html - vt220 only? + this._dirtyRowService.markRangeDirty(this._activeBuffer.y, this._activeBuffer.scrollBottom); + this._activeBuffer.x = 0; // see https://vt100.net/docs/vt220-rm/chapter4.html - vt220 only? return true; } @@ -1421,15 +1411,15 @@ export class InputHandler extends Disposable implements IInputHandler { */ public insertChars(params: IParams): boolean { this._restrictCursor(); - const line = this._bufferService.buffer.lines.get(this._bufferService.buffer.ybase + this._bufferService.buffer.y); + const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y); if (line) { line.insertCells( - this._bufferService.buffer.x, + this._activeBuffer.x, params.params[0] || 1, - this._bufferService.buffer.getNullCell(this._eraseAttrData()), + this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData() ); - this._dirtyRowService.markDirty(this._bufferService.buffer.y); + this._dirtyRowService.markDirty(this._activeBuffer.y); } return true; } @@ -1447,15 +1437,15 @@ export class InputHandler extends Disposable implements IInputHandler { */ public deleteChars(params: IParams): boolean { this._restrictCursor(); - const line = this._bufferService.buffer.lines.get(this._bufferService.buffer.ybase + this._bufferService.buffer.y); + const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y); if (line) { line.deleteCells( - this._bufferService.buffer.x, + this._activeBuffer.x, params.params[0] || 1, - this._bufferService.buffer.getNullCell(this._eraseAttrData()), + this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData() ); - this._dirtyRowService.markDirty(this._bufferService.buffer.y); + this._dirtyRowService.markDirty(this._activeBuffer.y); } return true; } @@ -1471,14 +1461,11 @@ export class InputHandler extends Disposable implements IInputHandler { public scrollUp(params: IParams): boolean { let param = params.params[0] || 1; - // make buffer local for faster access - const buffer = this._bufferService.buffer; - while (param--) { - buffer.lines.splice(buffer.ybase + buffer.scrollTop, 1); - buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 0, buffer.getBlankLine(this._eraseAttrData())); + this._activeBuffer.lines.splice(this._activeBuffer.ybase + this._activeBuffer.scrollTop, 1); + this._activeBuffer.lines.splice(this._activeBuffer.ybase + this._activeBuffer.scrollBottom, 0, this._activeBuffer.getBlankLine(this._eraseAttrData())); } - this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); + this._dirtyRowService.markRangeDirty(this._activeBuffer.scrollTop, this._activeBuffer.scrollBottom); return true; } @@ -1490,14 +1477,11 @@ export class InputHandler extends Disposable implements IInputHandler { public scrollDown(params: IParams): boolean { let param = params.params[0] || 1; - // make buffer local for faster access - const buffer = this._bufferService.buffer; - while (param--) { - buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 1); - buffer.lines.splice(buffer.ybase + buffer.scrollTop, 0, buffer.getBlankLine(DEFAULT_ATTR_DATA)); + this._activeBuffer.lines.splice(this._activeBuffer.ybase + this._activeBuffer.scrollBottom, 1); + this._activeBuffer.lines.splice(this._activeBuffer.ybase + this._activeBuffer.scrollTop, 0, this._activeBuffer.getBlankLine(DEFAULT_ATTR_DATA)); } - this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); + this._dirtyRowService.markRangeDirty(this._activeBuffer.scrollTop, this._activeBuffer.scrollBottom); return true; } @@ -1520,17 +1504,16 @@ export class InputHandler extends Disposable implements IInputHandler { * SL has no effect outside of the scroll margins. */ public scrollLeft(params: IParams): boolean { - const buffer = this._bufferService.buffer; - if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) { + if (this._activeBuffer.y > this._activeBuffer.scrollBottom || this._activeBuffer.y < this._activeBuffer.scrollTop) { return true; } const param = params.params[0] || 1; - for (let y = buffer.scrollTop; y <= buffer.scrollBottom; ++y) { - const line = buffer.lines.get(buffer.ybase + y)!; - line.deleteCells(0, param, buffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()); + for (let y = this._activeBuffer.scrollTop; y <= this._activeBuffer.scrollBottom; ++y) { + const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + y)!; + line.deleteCells(0, param, this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()); line.isWrapped = false; } - this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); + this._dirtyRowService.markRangeDirty(this._activeBuffer.scrollTop, this._activeBuffer.scrollBottom); return true; } @@ -1554,17 +1537,16 @@ export class InputHandler extends Disposable implements IInputHandler { * SL has no effect outside of the scroll margins. */ public scrollRight(params: IParams): boolean { - const buffer = this._bufferService.buffer; - if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) { + if (this._activeBuffer.y > this._activeBuffer.scrollBottom || this._activeBuffer.y < this._activeBuffer.scrollTop) { return true; } const param = params.params[0] || 1; - for (let y = buffer.scrollTop; y <= buffer.scrollBottom; ++y) { - const line = buffer.lines.get(buffer.ybase + y)!; - line.insertCells(0, param, buffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()); + for (let y = this._activeBuffer.scrollTop; y <= this._activeBuffer.scrollBottom; ++y) { + const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + y)!; + line.insertCells(0, param, this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()); line.isWrapped = false; } - this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); + this._dirtyRowService.markRangeDirty(this._activeBuffer.scrollTop, this._activeBuffer.scrollBottom); return true; } @@ -1578,17 +1560,16 @@ export class InputHandler extends Disposable implements IInputHandler { * DECIC has no effect outside the scrolling margins. */ public insertColumns(params: IParams): boolean { - const buffer = this._bufferService.buffer; - if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) { + if (this._activeBuffer.y > this._activeBuffer.scrollBottom || this._activeBuffer.y < this._activeBuffer.scrollTop) { return true; } const param = params.params[0] || 1; - for (let y = buffer.scrollTop; y <= buffer.scrollBottom; ++y) { - const line = this._bufferService.buffer.lines.get(buffer.ybase + y)!; - line.insertCells(buffer.x, param, buffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()); + for (let y = this._activeBuffer.scrollTop; y <= this._activeBuffer.scrollBottom; ++y) { + const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + y)!; + line.insertCells(this._activeBuffer.x, param, this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()); line.isWrapped = false; } - this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); + this._dirtyRowService.markRangeDirty(this._activeBuffer.scrollTop, this._activeBuffer.scrollBottom); return true; } @@ -1602,17 +1583,16 @@ export class InputHandler extends Disposable implements IInputHandler { * DECDC has no effect outside the scrolling margins. */ public deleteColumns(params: IParams): boolean { - const buffer = this._bufferService.buffer; - if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) { + if (this._activeBuffer.y > this._activeBuffer.scrollBottom || this._activeBuffer.y < this._activeBuffer.scrollTop) { return true; } const param = params.params[0] || 1; - for (let y = buffer.scrollTop; y <= buffer.scrollBottom; ++y) { - const line = buffer.lines.get(buffer.ybase + y)!; - line.deleteCells(buffer.x, param, buffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()); + for (let y = this._activeBuffer.scrollTop; y <= this._activeBuffer.scrollBottom; ++y) { + const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + y)!; + line.deleteCells(this._activeBuffer.x, param, this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData()); line.isWrapped = false; } - this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); + this._dirtyRowService.markRangeDirty(this._activeBuffer.scrollTop, this._activeBuffer.scrollBottom); return true; } @@ -1626,15 +1606,15 @@ export class InputHandler extends Disposable implements IInputHandler { */ public eraseChars(params: IParams): boolean { this._restrictCursor(); - const line = this._bufferService.buffer.lines.get(this._bufferService.buffer.ybase + this._bufferService.buffer.y); + const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + this._activeBuffer.y); if (line) { line.replaceCells( - this._bufferService.buffer.x, - this._bufferService.buffer.x + (params.params[0] || 1), - this._bufferService.buffer.getNullCell(this._eraseAttrData()), + this._activeBuffer.x, + this._activeBuffer.x + (params.params[0] || 1), + this._activeBuffer.getNullCell(this._eraseAttrData()), this._eraseAttrData() ); - this._dirtyRowService.markDirty(this._bufferService.buffer.y); + this._dirtyRowService.markDirty(this._activeBuffer.y); } return true; } @@ -2570,8 +2550,8 @@ export class InputHandler extends Disposable implements IInputHandler { break; case 6: // cursor position - const y = this._bufferService.buffer.y + 1; - const x = this._bufferService.buffer.x + 1; + const y = this._activeBuffer.y + 1; + const x = this._activeBuffer.x + 1; this._coreService.triggerDataEvent(`${C0.ESC}[${y};${x}R`); break; } @@ -2585,8 +2565,8 @@ export class InputHandler extends Disposable implements IInputHandler { switch (params.params[0]) { case 6: // cursor position - const y = this._bufferService.buffer.y + 1; - const x = this._bufferService.buffer.x + 1; + const y = this._activeBuffer.y + 1; + const x = this._activeBuffer.x + 1; this._coreService.triggerDataEvent(`${C0.ESC}[?${y};${x}R`); break; case 15: @@ -2631,18 +2611,18 @@ export class InputHandler extends Disposable implements IInputHandler { public softReset(params: IParams): boolean { this._coreService.isCursorHidden = false; this._onRequestSyncScrollBar.fire(); - this._bufferService.buffer.scrollTop = 0; - this._bufferService.buffer.scrollBottom = this._bufferService.rows - 1; + this._activeBuffer.scrollTop = 0; + this._activeBuffer.scrollBottom = this._bufferService.rows - 1; this._curAttrData = DEFAULT_ATTR_DATA.clone(); this._coreService.reset(); this._charsetService.reset(); // reset DECSC data - this._bufferService.buffer.savedX = 0; - this._bufferService.buffer.savedY = this._bufferService.buffer.ybase; - this._bufferService.buffer.savedCurAttrData.fg = this._curAttrData.fg; - this._bufferService.buffer.savedCurAttrData.bg = this._curAttrData.bg; - this._bufferService.buffer.savedCharset = this._charsetService.charset; + this._activeBuffer.savedX = 0; + this._activeBuffer.savedY = this._activeBuffer.ybase; + this._activeBuffer.savedCurAttrData.fg = this._curAttrData.fg; + this._activeBuffer.savedCurAttrData.bg = this._curAttrData.bg; + this._activeBuffer.savedCharset = this._charsetService.charset; // reset DECOM this._coreService.decPrivateModes.origin = false; @@ -2705,8 +2685,8 @@ export class InputHandler extends Disposable implements IInputHandler { } if (bottom > top) { - this._bufferService.buffer.scrollTop = top - 1; - this._bufferService.buffer.scrollBottom = bottom - 1; + this._activeBuffer.scrollTop = top - 1; + this._activeBuffer.scrollBottom = bottom - 1; this._setCursor(0, 0); } return true; @@ -2801,11 +2781,11 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y ESC SC "Save Cursor" "ESC 7" "Save cursor position, charmap and text attributes." */ public saveCursor(params?: IParams): boolean { - this._bufferService.buffer.savedX = this._bufferService.buffer.x; - this._bufferService.buffer.savedY = this._bufferService.buffer.ybase + this._bufferService.buffer.y; - this._bufferService.buffer.savedCurAttrData.fg = this._curAttrData.fg; - this._bufferService.buffer.savedCurAttrData.bg = this._curAttrData.bg; - this._bufferService.buffer.savedCharset = this._charsetService.charset; + this._activeBuffer.savedX = this._activeBuffer.x; + this._activeBuffer.savedY = this._activeBuffer.ybase + this._activeBuffer.y; + this._activeBuffer.savedCurAttrData.fg = this._curAttrData.fg; + this._activeBuffer.savedCurAttrData.bg = this._curAttrData.bg; + this._activeBuffer.savedCharset = this._charsetService.charset; return true; } @@ -2819,13 +2799,13 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y ESC RC "Restore Cursor" "ESC 8" "Restore cursor position, charmap and text attributes." */ public restoreCursor(params?: IParams): boolean { - this._bufferService.buffer.x = this._bufferService.buffer.savedX || 0; - this._bufferService.buffer.y = Math.max(this._bufferService.buffer.savedY - this._bufferService.buffer.ybase, 0); - this._curAttrData.fg = this._bufferService.buffer.savedCurAttrData.fg; - this._curAttrData.bg = this._bufferService.buffer.savedCurAttrData.bg; + this._activeBuffer.x = this._activeBuffer.savedX || 0; + this._activeBuffer.y = Math.max(this._activeBuffer.savedY - this._activeBuffer.ybase, 0); + this._curAttrData.fg = this._activeBuffer.savedCurAttrData.fg; + this._curAttrData.bg = this._activeBuffer.savedCurAttrData.bg; this._charsetService.charset = (this as any)._savedCharset; - if (this._bufferService.buffer.savedCharset) { - this._charsetService.charset = this._bufferService.buffer.savedCharset; + if (this._activeBuffer.savedCharset) { + this._charsetService.charset = this._activeBuffer.savedCharset; } this._restrictCursor(); return true; @@ -2907,7 +2887,7 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y ESC NEL "Next Line" "ESC E" "Move the cursor to the beginning of the next row." */ public nextLine(): boolean { - this._bufferService.buffer.x = 0; + this._activeBuffer.x = 0; this.index(); return true; } @@ -2987,13 +2967,12 @@ export class InputHandler extends Disposable implements IInputHandler { */ public index(): boolean { this._restrictCursor(); - const buffer = this._bufferService.buffer; - this._bufferService.buffer.y++; - if (buffer.y === buffer.scrollBottom + 1) { - buffer.y--; + this._activeBuffer.y++; + if (this._activeBuffer.y === this._activeBuffer.scrollBottom + 1) { + this._activeBuffer.y--; this._bufferService.scroll(this._eraseAttrData()); - } else if (buffer.y >= this._bufferService.rows) { - buffer.y = this._bufferService.rows - 1; + } else if (this._activeBuffer.y >= this._bufferService.rows) { + this._activeBuffer.y = this._bufferService.rows - 1; } this._restrictCursor(); return true; @@ -3010,7 +2989,7 @@ export class InputHandler extends Disposable implements IInputHandler { * @vt: #Y ESC HTS "Horizontal Tabulation Set" "ESC H" "Places a tab stop at the current cursor position." */ public tabSet(): boolean { - this._bufferService.buffer.tabs[this._bufferService.buffer.x] = true; + this._activeBuffer.tabs[this._activeBuffer.x] = true; return true; } @@ -3025,17 +3004,16 @@ export class InputHandler extends Disposable implements IInputHandler { */ public reverseIndex(): boolean { this._restrictCursor(); - const buffer = this._bufferService.buffer; - if (buffer.y === buffer.scrollTop) { + if (this._activeBuffer.y === this._activeBuffer.scrollTop) { // possibly move the code below to term.reverseScroll(); // test: echo -ne '\e[1;1H\e[44m\eM\e[0m' // blankLine(true) is xterm/linux behavior - const scrollRegionHeight = buffer.scrollBottom - buffer.scrollTop; - buffer.lines.shiftElements(buffer.ybase + buffer.y, scrollRegionHeight, 1); - buffer.lines.set(buffer.ybase + buffer.y, buffer.getBlankLine(this._eraseAttrData())); - this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); + const scrollRegionHeight = this._activeBuffer.scrollBottom - this._activeBuffer.scrollTop; + this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase + this._activeBuffer.y, scrollRegionHeight, 1); + this._activeBuffer.lines.set(this._activeBuffer.ybase + this._activeBuffer.y, this._activeBuffer.getBlankLine(this._eraseAttrData())); + this._dirtyRowService.markRangeDirty(this._activeBuffer.scrollTop, this._activeBuffer.scrollBottom); } else { - buffer.y--; + this._activeBuffer.y--; this._restrictCursor(); // quickfix to not run out of bounds } return true; @@ -3096,12 +3074,11 @@ export class InputHandler extends Disposable implements IInputHandler { cell.fg = this._curAttrData.fg; cell.bg = this._curAttrData.bg; - const buffer = this._bufferService.buffer; this._setCursor(0, 0); for (let yOffset = 0; yOffset < this._bufferService.rows; ++yOffset) { - const row = buffer.ybase + buffer.y + yOffset; - const line = buffer.lines.get(row); + const row = this._activeBuffer.ybase + this._activeBuffer.y + yOffset; + const line = this._activeBuffer.lines.get(row); if (line) { line.fill(cell); line.isWrapped = false; From aa046b73fb1bb269023aaabf3d2b4c93adf8b049 Mon Sep 17 00:00:00 2001 From: Simon Lamon Date: Wed, 1 Sep 2021 13:34:27 +0000 Subject: [PATCH 140/164] Handle undefined rows or cols better --- src/common/services/BufferService.ts | 4 ++-- src/common/services/OptionsService.test.ts | 14 ++++++++++++-- src/common/services/OptionsService.ts | 9 +++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/common/services/BufferService.ts b/src/common/services/BufferService.ts index 99594d228..c8c5f2731 100644 --- a/src/common/services/BufferService.ts +++ b/src/common/services/BufferService.ts @@ -36,8 +36,8 @@ export class BufferService extends Disposable implements IBufferService { @IOptionsService private _optionsService: IOptionsService ) { super(); - this.cols = Math.max(_optionsService.options.cols, MINIMUM_COLS); - this.rows = Math.max(_optionsService.options.rows, MINIMUM_ROWS); + this.cols = Math.max(_optionsService.options.cols || 0, MINIMUM_COLS); + this.rows = Math.max(_optionsService.options.rows || 0, MINIMUM_ROWS); this.buffers = new BufferSet(_optionsService, this); } diff --git a/src/common/services/OptionsService.test.ts b/src/common/services/OptionsService.test.ts index c289b5be1..e140b5b49 100644 --- a/src/common/services/OptionsService.test.ts +++ b/src/common/services/OptionsService.test.ts @@ -10,13 +10,23 @@ describe('OptionsService', () => { describe('constructor', () => { const originalError = console.error; beforeEach(() => { - console.error = () => {}; + console.error = () => { }; }); afterEach(() => { console.error = originalError; }); + it('uses default value if invalid constructor option values passed for cols/rows', () => { + const optionsService = new OptionsService({ cols: undefined, rows: undefined }); + assert.equal(optionsService.getOption('rows'), DEFAULT_OPTIONS.rows); + assert.equal(optionsService.getOption('cols'), DEFAULT_OPTIONS.cols); + }); + it('uses values from constructor option values if correctly passed', () => { + const optionsService = new OptionsService({ cols: 80, rows: 25 }); + assert.equal(optionsService.getOption('rows'), 25); + assert.equal(optionsService.getOption('cols'), 80); + }); it('uses default value if invalid constructor option value passed', () => { - assert.equal(new OptionsService({tabStopWidth: 0}).getOption('tabStopWidth'), DEFAULT_OPTIONS.tabStopWidth); + assert.equal(new OptionsService({ tabStopWidth: 0 }).getOption('tabStopWidth'), DEFAULT_OPTIONS.tabStopWidth); }); }); describe('setOption', () => { diff --git a/src/common/services/OptionsService.ts b/src/common/services/OptionsService.ts index 5add82833..d7ac1411d 100644 --- a/src/common/services/OptionsService.ts +++ b/src/common/services/OptionsService.ts @@ -22,7 +22,7 @@ export const DEFAULT_OPTIONS: ITerminalOptions = Object.freeze({ cursorStyle: 'block', cursorWidth: 1, customGlyphs: true, - bellSound: DEFAULT_BELL_SOUND, + bellSound: DEFAULT_BELL_SOUND, bellStyle: 'none', drawBoldTextInBrightColors: true, fastScrollModifier: 'alt', @@ -128,7 +128,7 @@ export class OptionsService implements IOptionsService { break; case 'cursorWidth': value = Math.floor(value); - // Fall through for bounds check + // Fall through for bounds check case 'lineHeight': case 'tabStopWidth': if (value < 1) { @@ -149,6 +149,11 @@ export class OptionsService implements IOptionsService { if (value <= 0) { throw new Error(`${key} cannot be less than or equal to 0, value: ${value}`); } + case 'rows': + case 'cols': + if (!value && value !== 0) { + throw new Error(`${key} must be numeric, value: ${value}`); + } break; } return value; From ffef3dba002e91ecac6b0d6a888fac1076cc7279 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 1 Sep 2021 06:41:10 -0700 Subject: [PATCH 141/164] Avoid property use and float->number conversion --- src/browser/Viewport.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/browser/Viewport.ts b/src/browser/Viewport.ts index 9ce14daf7..fecad811a 100644 --- a/src/browser/Viewport.ts +++ b/src/browser/Viewport.ts @@ -8,6 +8,8 @@ import { addDisposableDomListener } from 'browser/Lifecycle'; import { IColorSet, IViewport } from 'browser/Types'; import { ICharSizeService, IRenderService } from 'browser/services/Services'; import { IBufferService, IOptionsService } from 'common/services/Services'; +import { IBuffer } from 'common/buffer/Types'; +import { IRenderDimensions } from 'browser/renderer/Types'; const FALLBACK_SCROLL_BAR_WIDTH = 15; @@ -18,12 +20,15 @@ const FALLBACK_SCROLL_BAR_WIDTH = 15; export class Viewport extends Disposable implements IViewport { public scrollBarWidth: number = 0; private _currentRowHeight: number = 0; + private _currentScaledCellHeight: number = 0; private _lastRecordedBufferLength: number = 0; private _lastRecordedViewportHeight: number = 0; private _lastRecordedBufferHeight: number = 0; private _lastTouchY: number = 0; private _lastScrollTop: number = 0; private _lastHadScrollBar: boolean = false; + private _activeBuffer: IBuffer; + private _renderDimensions: IRenderDimensions; // Stores a partial line amount when scrolling, this is used to keep track of how much of a line // is scrolled so we can "scroll" over partial lines and feel natural on touchpads. This is a @@ -51,6 +56,12 @@ export class Viewport extends Disposable implements IViewport { this._lastHadScrollBar = true; this.register(addDisposableDomListener(this._viewportElement, 'scroll', this._onScroll.bind(this))); + // Track properties used in performance critical code manually to avoid using slow getters + this._activeBuffer = this._bufferService.buffer; + this.register(this._bufferService.buffers.onBufferActivate(e => this._activeBuffer = e.activeBuffer)); + this._renderDimensions = this._renderService.dimensions; + this.register(this._renderService.onDimensionsChange(e => this._renderDimensions = e)); + // Perform this async to ensure the ICharSizeService is ready. setTimeout(() => this.syncScrollArea(), 0); } @@ -79,6 +90,7 @@ export class Viewport extends Disposable implements IViewport { private _innerRefresh(): void { if (this._charSizeService.height > 0) { this._currentRowHeight = this._renderService.dimensions.scaledCellHeight / window.devicePixelRatio; + this._currentScaledCellHeight = this._renderService.dimensions.scaledCellHeight; this._lastRecordedViewportHeight = this._viewportElement.offsetHeight; const newBufferHeight = Math.round(this._currentRowHeight * this._lastRecordedBufferLength) + (this._lastRecordedViewportHeight - this._renderService.dimensions.canvasHeight); if (this._lastRecordedBufferHeight !== newBufferHeight) { @@ -126,8 +138,7 @@ export class Viewport extends Disposable implements IViewport { } // If the buffer position doesn't match last scroll top - const newScrollTop = this._bufferService.buffer.ydisp * this._currentRowHeight; - if (this._lastScrollTop !== newScrollTop) { + if (this._lastScrollTop !== this._activeBuffer.ydisp * this._currentRowHeight) { this._refresh(immediate); return; } @@ -139,7 +150,7 @@ export class Viewport extends Disposable implements IViewport { } // If row height changed - if (this._renderService.dimensions.scaledCellHeight / window.devicePixelRatio !== this._currentRowHeight) { + if (this._renderDimensions.scaledCellHeight !== this._currentScaledCellHeight) { this._refresh(immediate); return; } From 263c6d75bfccc34c0e926d44f9e79ab533b20bfd Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 1 Sep 2021 06:44:34 -0700 Subject: [PATCH 142/164] Avoid scrollTop call in hot code This seems to have been added in f6d5abf but it's not clear why, scroll APIs seem to work fine without it and using a DOM API here is causing slowness --- src/browser/Viewport.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/browser/Viewport.ts b/src/browser/Viewport.ts index fecad811a..3c9bea4c3 100644 --- a/src/browser/Viewport.ts +++ b/src/browser/Viewport.ts @@ -143,12 +143,6 @@ export class Viewport extends Disposable implements IViewport { return; } - // If element's scroll top changed, this can happen when hiding the element - if (this._lastScrollTop !== this._viewportElement.scrollTop) { - this._refresh(immediate); - return; - } - // If row height changed if (this._renderDimensions.scaledCellHeight !== this._currentScaledCellHeight) { this._refresh(immediate); From 3c8f600c572f16b63008e9d1bb6f56bf13325fdd Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 1 Sep 2021 11:27:14 -0700 Subject: [PATCH 143/164] fix #3348 --- addons/xterm-addon-webgl/src/WebglRenderer.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/xterm-addon-webgl/src/WebglRenderer.ts b/addons/xterm-addon-webgl/src/WebglRenderer.ts index 75b6230c1..a3b8ddef4 100644 --- a/addons/xterm-addon-webgl/src/WebglRenderer.ts +++ b/addons/xterm-addon-webgl/src/WebglRenderer.ts @@ -108,7 +108,9 @@ export class WebglRenderer extends Disposable implements IRenderer { for (const l of this._renderLayers) { l.dispose(); } - this._core.screenElement!.removeChild(this._canvas); + if (this._canvas.parentNode) { + this._core.screenElement?.removeChild(this._canvas); + } super.dispose(); } From 199e477349f8c5be149b1c9b57d23624ab1b65d6 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 1 Sep 2021 13:45:49 -0700 Subject: [PATCH 144/164] 3 -> 1 line --- addons/xterm-addon-webgl/src/WebglRenderer.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/addons/xterm-addon-webgl/src/WebglRenderer.ts b/addons/xterm-addon-webgl/src/WebglRenderer.ts index a3b8ddef4..9d8bde79c 100644 --- a/addons/xterm-addon-webgl/src/WebglRenderer.ts +++ b/addons/xterm-addon-webgl/src/WebglRenderer.ts @@ -108,9 +108,7 @@ export class WebglRenderer extends Disposable implements IRenderer { for (const l of this._renderLayers) { l.dispose(); } - if (this._canvas.parentNode) { - this._core.screenElement?.removeChild(this._canvas); - } + this._canvas.parentElement?.removeChild(this._canvas); super.dispose(); } From 453688a555b9589666c161b69e5167235d9c4b8a Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 2 Sep 2021 06:26:31 -0700 Subject: [PATCH 145/164] Split up unicode surrogates tests to avoid timeout Fixes #3441 --- src/browser/Terminal.test.ts | 144 +++++++++++++++++------------------ 1 file changed, 71 insertions(+), 73 deletions(-) diff --git a/src/browser/Terminal.test.ts b/src/browser/Terminal.test.ts index 84e6a87eb..a102d93f1 100644 --- a/src/browser/Terminal.test.ts +++ b/src/browser/Terminal.test.ts @@ -732,80 +732,78 @@ describe('Terminal', () => { }); describe('unicode - surrogates', () => { - it('2 characters per cell', async function (): Promise { - this.timeout(10000); // This is needed because istanbul patches code and slows it down - const high = String.fromCharCode(0xD800); - const cell = new CellData(); - for (let i = 0xDC00; i <= 0xDCFF; ++i) { - await term.writeP(high + String.fromCharCode(i)); - const tchar = term.buffer.lines.get(0)!.loadCell(0, cell); - assert.equal(tchar.getChars(), high + String.fromCharCode(i)); - assert.equal(tchar.getChars().length, 2); - assert.equal(tchar.getWidth(), 1); - assert.equal(term.buffer.lines.get(0)!.loadCell(1, cell).getChars(), ''); - term.reset(); - } - }); - it('2 characters at last cell', async () => { - const high = String.fromCharCode(0xD800); - const cell = new CellData(); - for (let i = 0xDC00; i <= 0xDCFF; ++i) { - term.buffer.x = term.cols - 1; - await term.writeP(high + String.fromCharCode(i)); - assert.equal(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars(), high + String.fromCharCode(i)); - assert.equal(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars().length, 2); - assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars(), ''); - term.reset(); - } - }); - it('2 characters per cell over line end with autowrap', async function (): Promise { - this.timeout(10000); - const high = String.fromCharCode(0xD800); - const cell = new CellData(); - for (let i = 0xDC00; i <= 0xDCFF; ++i) { - term.buffer.x = term.cols - 1; - - await term.writeP('a' + high + String.fromCharCode(i)); - assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars(), 'a'); - assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars(), high + String.fromCharCode(i)); - assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars().length, 2); - assert.equal(term.buffer.lines.get(1)!.loadCell(1, cell).getChars(), ''); - term.reset(); - } - }); - it('2 characters per cell over line end without autowrap', async function (): Promise { - this.timeout(10000); - const high = String.fromCharCode(0xD800); - const cell = new CellData(); - for (let i = 0xDC00; i <= 0xDCFF; ++i) { - term.buffer.x = term.cols - 1; - await term.writeP('\x1b[?7l'); // Disable wraparound mode - const width = wcwidth((0xD800 - 0xD800) * 0x400 + i - 0xDC00 + 0x10000); - if (width !== 1) { - continue; + for (let i = 0xDC00; i <= 0xDCF0; i += 0x10) { + const range = `0x${i.toString(16).toUpperCase()}-0x${(i + 0xF).toString(16).toUpperCase()}`; + it(`${range}: 2 characters per cell`, async function (): Promise { + const high = String.fromCharCode(0xD800); + const cell = new CellData(); + for (let j = i; j <= i + 0xF; j++) { + await term.writeP(high + String.fromCharCode(j)); + const tchar = term.buffer.lines.get(0)!.loadCell(0, cell); + assert.equal(tchar.getChars(), high + String.fromCharCode(j)); + assert.equal(tchar.getChars().length, 2); + assert.equal(tchar.getWidth(), 1); + assert.equal(term.buffer.lines.get(0)!.loadCell(1, cell).getChars(), ''); + term.reset(); } - await term.writeP('a' + high + String.fromCharCode(i)); - // auto wraparound mode should cut off the rest of the line - assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars(), high + String.fromCharCode(i)); - assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars().length, 2); - assert.equal(term.buffer.lines.get(1)!.loadCell(1, cell).getChars(), ''); - term.reset(); - } - }); - it('splitted surrogates', async function (): Promise { - this.timeout(10000); - const high = String.fromCharCode(0xD800); - const cell = new CellData(); - for (let i = 0xDC00; i <= 0xDCFF; ++i) { - await term.writeP(high + String.fromCharCode(i)); - const tchar = term.buffer.lines.get(0)!.loadCell(0, cell); - assert.equal(tchar.getChars(), high + String.fromCharCode(i)); - assert.equal(tchar.getChars().length, 2); - assert.equal(tchar.getWidth(), 1); - assert.equal(term.buffer.lines.get(0)!.loadCell(1, cell).getChars(), ''); - term.reset(); - } - }); + }); + it(`${range}: 2 characters at last cell`, async () => { + const high = String.fromCharCode(0xD800); + const cell = new CellData(); + term.buffer.x = term.cols - 1; + for (let j = i; j <= i + 0xF; j++) { + await term.writeP(high + String.fromCharCode(j)); + assert.equal(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars(), high + String.fromCharCode(j)); + assert.equal(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars().length, 2); + assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars(), ''); + term.reset(); + } + }); + it(`${range}: 2 characters per cell over line end with autowrap`, async function (): Promise { + const high = String.fromCharCode(0xD800); + const cell = new CellData(); + for (let j = i; j <= i + 0xF; j++) { + term.buffer.x = term.cols - 1; + await term.writeP('a' + high + String.fromCharCode(j)); + assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars(), 'a'); + assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars(), high + String.fromCharCode(j)); + assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars().length, 2); + assert.equal(term.buffer.lines.get(1)!.loadCell(1, cell).getChars(), ''); + term.reset(); + } + }); + it(`${range}: 2 characters per cell over line end without autowrap`, async function (): Promise { + const high = String.fromCharCode(0xD800); + const cell = new CellData(); + for (let j = i; j <= i + 0xF; j++) { + term.buffer.x = term.cols - 1; + await term.writeP('\x1b[?7l'); // Disable wraparound mode + const width = wcwidth((0xD800 - 0xD800) * 0x400 + j - 0xDC00 + 0x10000); + if (width !== 1) { + continue; + } + await term.writeP('a' + high + String.fromCharCode(j)); + // auto wraparound mode should cut off the rest of the line + assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars(), high + String.fromCharCode(j)); + assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars().length, 2); + assert.equal(term.buffer.lines.get(1)!.loadCell(1, cell).getChars(), ''); + term.reset(); + } + }); + it(`${range}: splitted surrogates`, async function (): Promise { + const high = String.fromCharCode(0xD800); + const cell = new CellData(); + for (let j = i; j <= i + 0xF; j++) { + await term.writeP(high + String.fromCharCode(j)); + const tchar = term.buffer.lines.get(0)!.loadCell(0, cell); + assert.equal(tchar.getChars(), high + String.fromCharCode(j)); + assert.equal(tchar.getChars().length, 2); + assert.equal(tchar.getWidth(), 1); + assert.equal(term.buffer.lines.get(0)!.loadCell(1, cell).getChars(), ''); + term.reset(); + } + }); + } }); describe('unicode - combining characters', () => { From 20460a2be19c72956d0519fa49658a437f54416c Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 2 Sep 2021 07:34:04 -0700 Subject: [PATCH 146/164] Fire buffer activate event on buffer service reset --- src/common/buffer/BufferSet.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/buffer/BufferSet.ts b/src/common/buffer/BufferSet.ts index b74c4eac7..de220e8ff 100644 --- a/src/common/buffer/BufferSet.ts +++ b/src/common/buffer/BufferSet.ts @@ -42,6 +42,10 @@ export class BufferSet extends Disposable implements IBufferSet { // See http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer this._alt = new Buffer(false, this._optionsService, this._bufferService); this._activeBuffer = this._normal; + this._onBufferActivate.fire({ + activeBuffer: this._normal, + inactiveBuffer: this._alt + }); this.setupTabStops(); } From fa778257b9c7f1fb973e3bd63fa1fea01bc3fd14 Mon Sep 17 00:00:00 2001 From: Simon Lamon Date: Fri, 3 Sep 2021 04:40:29 +0000 Subject: [PATCH 147/164] Formatting --- src/common/services/OptionsService.test.ts | 4 ++-- src/common/services/OptionsService.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/services/OptionsService.test.ts b/src/common/services/OptionsService.test.ts index e140b5b49..8675b6b99 100644 --- a/src/common/services/OptionsService.test.ts +++ b/src/common/services/OptionsService.test.ts @@ -10,7 +10,7 @@ describe('OptionsService', () => { describe('constructor', () => { const originalError = console.error; beforeEach(() => { - console.error = () => { }; + console.error = () => {}; }); afterEach(() => { console.error = originalError; @@ -26,7 +26,7 @@ describe('OptionsService', () => { assert.equal(optionsService.getOption('cols'), 80); }); it('uses default value if invalid constructor option value passed', () => { - assert.equal(new OptionsService({ tabStopWidth: 0 }).getOption('tabStopWidth'), DEFAULT_OPTIONS.tabStopWidth); + assert.equal(new OptionsService({tabStopWidth: 0}).getOption('tabStopWidth'), DEFAULT_OPTIONS.tabStopWidth); }); }); describe('setOption', () => { diff --git a/src/common/services/OptionsService.ts b/src/common/services/OptionsService.ts index d7ac1411d..e9dcaa6a7 100644 --- a/src/common/services/OptionsService.ts +++ b/src/common/services/OptionsService.ts @@ -22,7 +22,7 @@ export const DEFAULT_OPTIONS: ITerminalOptions = Object.freeze({ cursorStyle: 'block', cursorWidth: 1, customGlyphs: true, - bellSound: DEFAULT_BELL_SOUND, + bellSound: DEFAULT_BELL_SOUND, bellStyle: 'none', drawBoldTextInBrightColors: true, fastScrollModifier: 'alt', @@ -128,7 +128,7 @@ export class OptionsService implements IOptionsService { break; case 'cursorWidth': value = Math.floor(value); - // Fall through for bounds check + // Fall through for bounds check case 'lineHeight': case 'tabStopWidth': if (value < 1) { From 3eeec144628a571aef2cb675b294e4070af5523c Mon Sep 17 00:00:00 2001 From: anirudh1713 Date: Sun, 5 Sep 2021 20:35:07 +0530 Subject: [PATCH 148/164] switch active unicode version in demo --- demo/client.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/demo/client.ts b/demo/client.ts index a02b155ca..a5ac8bb51 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -377,6 +377,9 @@ function initAddons(term: TerminalType): void { if (!addon.canChange) { checkbox.disabled = true; } + if(name === 'unicode11' && checkbox.checked) { + term.unicode.activeVersion = '11'; + } addDomListener(checkbox, 'change', () => { if (checkbox.checked) { addon.instance = new addon.ctor(); @@ -385,10 +388,14 @@ function initAddons(term: TerminalType): void { setTimeout(() => { document.body.appendChild((addon.instance as WebglAddon).textureAtlas); }, 0); + } else if (name === 'unicode11') { + term.unicode.activeVersion = '11'; } } else { if (name === 'webgl') { document.body.removeChild((addon.instance as WebglAddon).textureAtlas); + } else if (name === 'unicode11') { + term.unicode.activeVersion = '6'; } addon.instance!.dispose(); addon.instance = undefined; From 3cb374076a2f408882303c4124bfedf0705f3062 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 9 Sep 2021 05:49:04 -0700 Subject: [PATCH 149/164] v4.14.0 --- addons/xterm-addon-search/package.json | 2 +- addons/xterm-addon-serialize/package.json | 2 +- addons/xterm-addon-unicode11/package.json | 2 +- addons/xterm-addon-webgl/package.json | 2 +- package.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/xterm-addon-search/package.json b/addons/xterm-addon-search/package.json index 659bd834e..08fe195fe 100644 --- a/addons/xterm-addon-search/package.json +++ b/addons/xterm-addon-search/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-search", - "version": "0.8.0", + "version": "0.8.1", "author": { "name": "The xterm.js authors", "url": "https://xtermjs.org/" diff --git a/addons/xterm-addon-serialize/package.json b/addons/xterm-addon-serialize/package.json index 91ef26afd..77a54dbf9 100644 --- a/addons/xterm-addon-serialize/package.json +++ b/addons/xterm-addon-serialize/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-serialize", - "version": "0.5.0", + "version": "0.6.0", "author": { "name": "The xterm.js authors", "url": "https://xtermjs.org/" diff --git a/addons/xterm-addon-unicode11/package.json b/addons/xterm-addon-unicode11/package.json index 397bf2b9c..9fc69416e 100644 --- a/addons/xterm-addon-unicode11/package.json +++ b/addons/xterm-addon-unicode11/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-unicode11", - "version": "0.2.0", + "version": "0.3.0", "author": { "name": "The xterm.js authors", "url": "https://xtermjs.org/" diff --git a/addons/xterm-addon-webgl/package.json b/addons/xterm-addon-webgl/package.json index 421f6092f..226f34ba4 100644 --- a/addons/xterm-addon-webgl/package.json +++ b/addons/xterm-addon-webgl/package.json @@ -1,6 +1,6 @@ { "name": "xterm-addon-webgl", - "version": "0.11.1", + "version": "0.11.2", "author": { "name": "The xterm.js authors", "url": "https://xtermjs.org/" diff --git a/package.json b/package.json index 29b6fd46f..1b2bfb672 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "xterm", "description": "Full xterm terminal, in your browser", - "version": "4.13.0", + "version": "4.14.0", "main": "lib/xterm.js", "style": "css/xterm.css", "types": "typings/xterm.d.ts", From 662154123da91fdce991bf7b6a4f4c5f8c826eb4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 9 Sep 2021 13:24:07 +0000 Subject: [PATCH 150/164] Bump axios from 0.18.1 to 0.21.2 in /addons/xterm-addon-ligatures Bumps [axios](https://github.com/axios/axios) from 0.18.1 to 0.21.2. - [Release notes](https://github.com/axios/axios/releases) - [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md) - [Commits](https://github.com/axios/axios/compare/v0.18.1...v0.21.2) --- updated-dependencies: - dependency-name: axios dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- addons/xterm-addon-ligatures/package.json | 2 +- addons/xterm-addon-ligatures/yarn.lock | 33 +++++++---------------- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/addons/xterm-addon-ligatures/package.json b/addons/xterm-addon-ligatures/package.json index ecbcc0066..b1688772a 100644 --- a/addons/xterm-addon-ligatures/package.json +++ b/addons/xterm-addon-ligatures/package.json @@ -36,7 +36,7 @@ }, "devDependencies": { "@types/sinon": "^5.0.1", - "axios": "^0.18.0", + "axios": "^0.21.2", "mkdirp": "0.5.5", "sinon": "6.3.5", "yauzl": "^2.10.0" diff --git a/addons/xterm-addon-ligatures/yarn.lock b/addons/xterm-addon-ligatures/yarn.lock index 2aac858b1..f6ce913b5 100644 --- a/addons/xterm-addon-ligatures/yarn.lock +++ b/addons/xterm-addon-ligatures/yarn.lock @@ -45,23 +45,17 @@ array-from@^2.1.1: resolved "https://registry.yarnpkg.com/array-from/-/array-from-2.1.1.tgz#cfe9d8c26628b9dc5aecc62a9f5d8f1f352c1195" integrity sha1-z+nYwmYoudxa7MYqn12PHzUsEZU= -axios@^0.18.0: - version "0.18.1" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.18.1.tgz#ff3f0de2e7b5d180e757ad98000f1081b87bcea3" +axios@^0.21.2: + version "0.21.2" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.2.tgz#21297d5084b2aeeb422f5d38e7be4fbb82239017" + integrity sha512-87otirqUw3e8CzHTMO+/9kh/FSgXt/eVDvipijwDtEuwbkySWZ9SBm6VEubmJ/kLKEoLQV/POhxXFb66bfekfg== dependencies: - follow-redirects "1.5.10" - is-buffer "^2.0.2" + follow-redirects "^1.14.0" buffer-crc32@~0.2.3: version "0.2.13" resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" -debug@=3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" - dependencies: - ms "2.0.0" - diff@^3.5.0: version "3.5.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" @@ -72,11 +66,10 @@ fd-slicer@~1.1.0: dependencies: pend "~1.2.0" -follow-redirects@1.5.10: - version "1.5.10" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a" - dependencies: - debug "=3.1.0" +follow-redirects@^1.14.0: + version "1.14.3" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.3.tgz#6ada78118d8d24caee595595accdc0ac6abd022e" + integrity sha512-3MkHxknWMUtb23apkgz/83fDoe+y+qr0TdgacGIA7bew+QLBo3vdgEN2xEsuXNivpFy4CyDhBBZnNZOtalmenw== font-finder@^1.0.3: version "1.0.4" @@ -110,10 +103,6 @@ has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" -is-buffer@^2.0.2: - version "2.0.3" - resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.3.tgz#4ecf3fcf749cbd1e472689e109ac66261a25e725" - isarray@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" @@ -163,10 +152,6 @@ mkdirp@0.5.5: dependencies: minimist "^1.2.5" -ms@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" - nise@^1.4.5: version "1.5.3" resolved "https://registry.yarnpkg.com/nise/-/nise-1.5.3.tgz#9d2cfe37d44f57317766c6e9408a359c5d3ac1f7" From 5a65fd9c6ab244637b4c76199d4c1aeb7da6c8a3 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 10 Sep 2021 09:42:19 -0700 Subject: [PATCH 151/164] Disable emoji ime when screenReaderMode is on Fixes #3467 --- src/browser/Terminal.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index ebe755bc4..d28be5bf2 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -1180,7 +1180,9 @@ export class Terminal extends CoreTerminal implements ITerminal { * @param ev The input event to be handled. */ protected _inputEvent(ev: InputEvent): boolean { - if (ev.data && ev.inputType === 'insertText') { + // Only support emoji IMEs when screen reader mode is disabled as the event must bubble up to + // support reading out character input which can doubling up input characters + if (ev.data && ev.inputType === 'insertText' && !this.optionsService.options.screenReaderMode) { if (this._keyPressHandled) { return false; } From db6b3c4bcc4cf0934a71752e9c13ff2ade4174cd Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 10 Sep 2021 09:44:29 -0700 Subject: [PATCH 152/164] v4.14.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1b2bfb672..ad288f494 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "xterm", "description": "Full xterm terminal, in your browser", - "version": "4.14.0", + "version": "4.14.1", "main": "lib/xterm.js", "style": "css/xterm.css", "types": "typings/xterm.d.ts", From c186fbeafcc907bb2e6af80c4485a255b8c4e778 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 15 Sep 2021 05:04:11 -0700 Subject: [PATCH 153/164] Add exclude mode/alt buffer options to serialize addon Fixes #3472 --- .../src/SerializeAddon.ts | 23 +++++++++++---- .../test/SerializeAddon.api.ts | 4 +-- .../typings/xterm-addon-serialize.d.ts | 29 +++++++++++++++---- 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index a54b43257..d692c8189 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -433,26 +433,37 @@ export class SerializeAddon implements ITerminalAddon { return content; } - public serialize(scrollback?: number): string { + public serialize(options?: ISerializeOptions): string { // TODO: Add combinedData support if (!this._terminal) { throw new Error('Cannot use addon until it has been loaded'); } // Normal buffer - let content = this._serializeBuffer(this._terminal, this._terminal.buffer.normal, scrollback); + let content = this._serializeBuffer(this._terminal, this._terminal.buffer.normal, options?.scrollback); // Alternate buffer - if (this._terminal.buffer.active.type === 'alternate') { - const alternativeScreenContent = this._serializeBuffer(this._terminal, this._terminal.buffer.alternate, undefined); - content += `\u001b[?1049h\u001b[H${alternativeScreenContent}`; + if (!options?.excludeAltBuffer) { + if (this._terminal.buffer.active.type === 'alternate') { + const alternativeScreenContent = this._serializeBuffer(this._terminal, this._terminal.buffer.alternate, undefined); + content += `\u001b[?1049h\u001b[H${alternativeScreenContent}`; + } } // Modes - content += this._serializeModes(this._terminal); + if (!options?.excludeModes) { + content += this._serializeModes(this._terminal); + } return content; } public dispose(): void { } } + + +interface ISerializeOptions { + scrollback?: number; + excludeModes?: boolean; + excludeAltBuffer?: boolean; +} diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index bb66f37b2..c8593b72c 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -146,7 +146,7 @@ describe('SerializeAddon', () => { const cols = 10; const lines = newArray((index: number) => digitsString(cols, index), rows); await writeSync(page, lines.join('\\r\\n')); - assert.equal(await page.evaluate(`serializeAddon.serialize(${halfScrollback});`), lines.slice(halfScrollback, rows).join('\r\n')); + assert.equal(await page.evaluate(`serializeAddon.serialize({ scrollback: ${halfScrollback} });`), lines.slice(halfScrollback, rows).join('\r\n')); }); it('serialize 0 rows of scrollback', async function(): Promise { @@ -154,7 +154,7 @@ describe('SerializeAddon', () => { const cols = 10; const lines = newArray((index: number) => digitsString(cols, index), rows); await writeSync(page, lines.join('\\r\\n')); - assert.equal(await page.evaluate(`serializeAddon.serialize(0);`), lines.slice(rows - 10, rows).join('\r\n')); + assert.equal(await page.evaluate(`serializeAddon.serialize({ scrollback: 0 });`), lines.slice(rows - 10, rows).join('\r\n')); }); it('serialize all rows of content with color16', async function(): Promise { diff --git a/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts b/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts index b55ee303d..a29dbb286 100644 --- a/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts +++ b/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts @@ -7,14 +7,14 @@ import { Terminal, ITerminalAddon } from 'xterm'; declare module 'xterm-addon-serialize' { /** - * An xterm.js addon that enables web links. + * An xterm.js addon that enables serialization of terminal contents. */ export class SerializeAddon implements ITerminalAddon { constructor(); /** - * Activates the addon + * Activates the addon. * @param terminal The terminal the addon is being loaded in. */ public activate(terminal: Terminal): void; @@ -24,15 +24,32 @@ declare module 'xterm-addon-serialize' { * the state. The cursor will also be positioned to the correct cell. When restoring a terminal * it is best to do before `Terminal.open` is called to avoid wasting CPU cycles rendering * incomplete frames. - * @param scrollback The number of rows in scrollback buffer to serialize, starting from the - * bottom of the scrollback buffer. This defaults to the all available rows in the scrollback - * buffer. + * @param options Custom options to allow control over what gets serialized. */ - public serialize(scrollback?: number): string; + public serialize(options?: ISerializeOptions): string; /** * Disposes the addon. */ public dispose(): void; } + + export interface ISerializeOptions { + /** + * The number of rows in the scrollback buffer to serialize, starting from the bottom of the + * scrollback buffer. When not specified, all available rows in the scrollback buffer will be + * serialized. + */ + scrollback?: number; + + /** + * Whether to exclude the terminal modes from the serialization. False by default. + */ + excludeModes?: boolean; + + /** + * Whether to exclude the alt buffer from the serialization. False by default. + */ + excludeAltBuffer?: boolean; + } } From 6493edcddf2b987afd927ad50a642b0abafb5b46 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 15 Sep 2021 05:40:46 -0700 Subject: [PATCH 154/164] Add new serialize option tests --- .../xterm-addon-serialize/test/SerializeAddon.api.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index c8593b72c..5fc1bfaf1 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -157,6 +157,18 @@ describe('SerializeAddon', () => { assert.equal(await page.evaluate(`serializeAddon.serialize({ scrollback: 0 });`), lines.slice(rows - 10, rows).join('\r\n')); }); + it('serialize exclude modes', async () => { + await writeSync(page, 'before\\x1b[?1hafter'); + assert.equal(await page.evaluate(`serializeAddon.serialize();`), 'beforeafter\x1b[?1h'); + assert.equal(await page.evaluate(`serializeAddon.serialize({ excludeModes: true });`), 'beforeafter'); + }); + + it('serialize exclude alt buffer', async () => { + await writeSync(page, 'normal\\x1b[?1049h\\x1b[Halt'); + assert.equal(await page.evaluate(`serializeAddon.serialize();`), 'normal\x1b[?1049h\x1b[Halt'); + assert.equal(await page.evaluate(`serializeAddon.serialize({ excludeAltBuffer: true });`), 'normal'); + }); + it('serialize all rows of content with color16', async function(): Promise { const cols = 10; const color16 = [ From 2e4e29ad73174757632be34fb0d0c11377e3e803 Mon Sep 17 00:00:00 2001 From: Simon Lamon Date: Wed, 22 Sep 2021 08:47:36 +0000 Subject: [PATCH 155/164] Support strikethrough in serialize addon --- addons/xterm-addon-serialize/src/SerializeAddon.ts | 6 ++++-- typings/xterm-headless.d.ts | 12 +++++++----- typings/xterm.d.ts | 10 ++++++---- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/addons/xterm-addon-serialize/src/SerializeAddon.ts b/addons/xterm-addon-serialize/src/SerializeAddon.ts index a54b43257..41195a7e0 100644 --- a/addons/xterm-addon-serialize/src/SerializeAddon.ts +++ b/addons/xterm-addon-serialize/src/SerializeAddon.ts @@ -72,7 +72,8 @@ function equalFlags(cell1: IBufferCell, cell2: IBufferCell): boolean { && cell1.isBlink() === cell2.isBlink() && cell1.isInvisible() === cell2.isInvisible() && cell1.isItalic() === cell2.isItalic() - && cell1.isDim() === cell2.isDim(); + && cell1.isDim() === cell2.isDim() + && cell1.isStrikethrough() === cell2.isStrikethrough(); } class StringSerializeHandler extends BaseSerializeHandler { @@ -160,7 +161,7 @@ class StringSerializeHandler extends BaseSerializeHandler { if ( // you must output character to cause overflow, control sequence can't do this nextRowFirstChar.getChars() && - isNextRowFirstCharDoubleWidth ? this._nullCellCount <= 1 : this._nullCellCount <= 0 + isNextRowFirstCharDoubleWidth ? this._nullCellCount <= 1 : this._nullCellCount <= 0 ) { if ( // the last character can't be null, @@ -259,6 +260,7 @@ class StringSerializeHandler extends BaseSerializeHandler { if (cell.isInvisible() !== oldCell.isInvisible()) { sgrSeq.push(cell.isInvisible() ? 8 : 28); } if (cell.isItalic() !== oldCell.isItalic()) { sgrSeq.push(cell.isItalic() ? 3 : 23); } if (cell.isDim() !== oldCell.isDim()) { sgrSeq.push(cell.isDim() ? 2 : 22); } + if (cell.isStrikethrough() !== oldCell.isStrikethrough()) { sgrSeq.push(cell.isStrikethrough() ? 9 : 29); } } } } diff --git a/typings/xterm-headless.d.ts b/typings/xterm-headless.d.ts index 13a321261..84b715e86 100644 --- a/typings/xterm-headless.d.ts +++ b/typings/xterm-headless.d.ts @@ -84,7 +84,7 @@ declare module 'xterm-headless' { * line height and letter spacing is used. Note that this doesn't work with the DOM renderer * which renders all characters using the font. The default is true. */ - customGlyphs?: boolean; + customGlyphs?: boolean; /** * Whether input should be disabled. @@ -1085,18 +1085,20 @@ declare module 'xterm-headless' { /** Whether the cell has the bold attribute (CSI 1 m). */ isBold(): number; - /** Whether the cell has the inverse attribute (CSI 3 m). */ + /** Whether the cell has the italic attribute (CSI 3 m). */ isItalic(): number; - /** Whether the cell has the inverse attribute (CSI 2 m). */ + /** Whether the cell has the dim attribute (CSI 2 m). */ isDim(): number; /** Whether the cell has the underline attribute (CSI 4 m). */ isUnderline(): number; - /** Whether the cell has the inverse attribute (CSI 5 m). */ + /** Whether the cell has the blink attribute (CSI 5 m). */ isBlink(): number; /** Whether the cell has the inverse attribute (CSI 7 m). */ isInverse(): number; - /** Whether the cell has the inverse attribute (CSI 8 m). */ + /** Whether the cell has the invisible attribute (CSI 8 m). */ isInvisible(): number; + /** Whether the cell has the strikethrough attribute (CSI 9 m). */ + isStrikethrough(): number; /** Whether the cell is using the RGB foreground color mode. */ isFgRGB(): boolean; diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index ba2be9881..6cf34bf85 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -1444,18 +1444,20 @@ declare module 'xterm' { /** Whether the cell has the bold attribute (CSI 1 m). */ isBold(): number; - /** Whether the cell has the inverse attribute (CSI 3 m). */ + /** Whether the cell has the italic attribute (CSI 3 m). */ isItalic(): number; - /** Whether the cell has the inverse attribute (CSI 2 m). */ + /** Whether the cell has the dim attribute (CSI 2 m). */ isDim(): number; /** Whether the cell has the underline attribute (CSI 4 m). */ isUnderline(): number; - /** Whether the cell has the inverse attribute (CSI 5 m). */ + /** Whether the cell has the blink attribute (CSI 5 m). */ isBlink(): number; /** Whether the cell has the inverse attribute (CSI 7 m). */ isInverse(): number; - /** Whether the cell has the inverse attribute (CSI 8 m). */ + /** Whether the cell has the invisible attribute (CSI 8 m). */ isInvisible(): number; + /** Whether the cell has the strikethrough attribute (CSI 9 m). */ + isStrikethrough(): number; /** Whether the cell is using the RGB foreground color mode. */ isFgRGB(): boolean; From 3fe32c07246937729719e576ae5453f30b21edf6 Mon Sep 17 00:00:00 2001 From: Simon Lamon Date: Wed, 22 Sep 2021 09:38:37 +0000 Subject: [PATCH 156/164] Adjust test to include strikethrough test --- .../test/SerializeAddon.api.ts | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts index bb66f37b2..975252261 100644 --- a/addons/xterm-addon-serialize/test/SerializeAddon.api.ts +++ b/addons/xterm-addon-serialize/test/SerializeAddon.api.ts @@ -184,11 +184,13 @@ describe('SerializeAddon', () => { sgr(UNDERLINED) + line, sgr(BLINK) + line, sgr(INVISIBLE) + line, + sgr(STRIKETHROUGH) + line, sgr(NO_INVERSE) + line, sgr(NO_BOLD) + line, sgr(NO_UNDERLINED) + line, sgr(NO_BLINK) + line, - sgr(NO_INVISIBLE) + line + sgr(NO_INVISIBLE) + line, + sgr(NO_STRIKETHROUGH) + line ]; const rows = lines.length; await writeSync(page, lines.join('\\r\\n')); @@ -579,20 +581,20 @@ const BG_RGB_GREEN = '48;2;0;255;0'; const BG_RGB_YELLOW = '48;2;255;255;0'; const BG_RESET = '49'; -const INVERSE = '7'; const BOLD = '1'; +const DIM = '2'; +const ITALIC = '3'; const UNDERLINED = '4'; const BLINK = '5'; +const INVERSE = '7'; const INVISIBLE = '8'; +const STRIKETHROUGH = '9'; -const NO_INVERSE = '27'; const NO_BOLD = '22'; +const NO_DIM = '22'; +const NO_ITALIC = '23'; const NO_UNDERLINED = '24'; const NO_BLINK = '25'; +const NO_INVERSE = '27'; const NO_INVISIBLE = '28'; - -const ITALIC = '3'; -const DIM = '2'; - -const NO_ITALIC = '23'; -const NO_DIM = '22'; +const NO_STRIKETHROUGH = '29'; From 189ff562242baa8cb9dea7c510b9377da9cd39a2 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 22 Sep 2021 06:38:47 -0700 Subject: [PATCH 157/164] Add API to clear canvas renderer texture atlas Fixes #3455 --- src/browser/Terminal.ts | 4 ++++ src/browser/TestUtils.test.ts | 6 ++++++ src/browser/Types.d.ts | 1 + src/browser/public/Terminal.ts | 3 +++ src/browser/renderer/BaseRenderLayer.ts | 4 ++++ src/browser/renderer/Renderer.ts | 6 ++++++ src/browser/renderer/Types.d.ts | 6 ++++++ src/browser/renderer/atlas/BaseCharAtlas.ts | 2 ++ src/browser/renderer/atlas/DynamicCharAtlas.ts | 10 ++++++++++ src/browser/services/RenderService.ts | 5 +++++ src/browser/services/Services.ts | 1 + typings/xterm.d.ts | 8 ++++++++ 12 files changed, 56 insertions(+) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index ebe755bc4..4e6a22015 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -1290,6 +1290,10 @@ export class Terminal extends CoreTerminal implements ITerminal { this.viewport?.syncScrollArea(); } + public clearTextureAtlas(): void { + this._renderService?.clearTextureAtlas(); + } + private _reportWindowsOptions(type: WindowsOptionsReportType): void { if (!this._renderService) { return; diff --git a/src/browser/TestUtils.test.ts b/src/browser/TestUtils.test.ts index daa6843c3..8fdf458e6 100644 --- a/src/browser/TestUtils.test.ts +++ b/src/browser/TestUtils.test.ts @@ -195,6 +195,9 @@ export class MockTerminal implements ITerminal { public reset(): void { throw new Error('Method not implemented.'); } + public clearTextureAtlas(): void { + throw new Error('Method not implemented.'); + } public refresh(start: number, end: number): void { throw new Error('Method not implemented.'); } @@ -374,6 +377,9 @@ export class MockRenderService implements IRenderService { public refreshRows(start: number, end: number): void { throw new Error('Method not implemented.'); } + public clearTextureAtlas(): void { + throw new Error('Method not implemented.'); + } public resize(cols: number, rows: number): void { throw new Error('Method not implemented.'); } diff --git a/src/browser/Types.d.ts b/src/browser/Types.d.ts index 0d74b39fa..bafeff77c 100644 --- a/src/browser/Types.d.ts +++ b/src/browser/Types.d.ts @@ -79,6 +79,7 @@ export interface IPublicTerminal extends IDisposable { write(data: string | Uint8Array, callback?: () => void): void; paste(data: string): void; refresh(start: number, end: number): void; + clearTextureAtlas(): void; reset(): void; } diff --git a/src/browser/public/Terminal.ts b/src/browser/public/Terminal.ts index a76b1a229..26cf27288 100644 --- a/src/browser/public/Terminal.ts +++ b/src/browser/public/Terminal.ts @@ -222,6 +222,9 @@ export class Terminal implements ITerminalApi { public reset(): void { this._core.reset(); } + public clearTextureAtlas(): void { + this._core.clearTextureAtlas(); + } public loadAddon(addon: ITerminalAddon): void { return this._addonManager.loadAddon(this, addon); } diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 448451d01..68f83a75f 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -138,6 +138,10 @@ export abstract class BaseRenderLayer implements IRenderLayer { public abstract reset(): void; + public clearTextureAtlas(): void { + this._charAtlas?.clear(); + } + /** * Fills 1+ cells completely. This uses the existing fillStyle on the context. * @param x The column to start at. diff --git a/src/browser/renderer/Renderer.ts b/src/browser/renderer/Renderer.ts index d5de40db8..162a7ed3b 100644 --- a/src/browser/renderer/Renderer.ts +++ b/src/browser/renderer/Renderer.ts @@ -149,6 +149,12 @@ export class Renderer extends Disposable implements IRenderer { } } + public clearTextureAtlas(): void { + for (const layer of this._renderLayers) { + layer.clearTextureAtlas(); + } + } + /** * Recalculates the character and canvas dimensions. */ diff --git a/src/browser/renderer/Types.d.ts b/src/browser/renderer/Types.d.ts index fc137bc8f..6818a9267 100644 --- a/src/browser/renderer/Types.d.ts +++ b/src/browser/renderer/Types.d.ts @@ -52,6 +52,7 @@ export interface IRenderer extends IDisposable { onOptionsChanged(): void; clear(): void; renderRows(start: number, end: number): void; + clearTextureAtlas?(): void; } export interface IRenderLayer extends IDisposable { @@ -100,4 +101,9 @@ export interface IRenderLayer extends IDisposable { * Clear the state of the render layer. */ reset(): void; + + /** + * Clears the texture atlas. + */ + clearTextureAtlas(): void; } diff --git a/src/browser/renderer/atlas/BaseCharAtlas.ts b/src/browser/renderer/atlas/BaseCharAtlas.ts index 4ebaaa471..83c30d2f0 100644 --- a/src/browser/renderer/atlas/BaseCharAtlas.ts +++ b/src/browser/renderer/atlas/BaseCharAtlas.ts @@ -28,6 +28,8 @@ export abstract class BaseCharAtlas implements IDisposable { */ private _doWarmUp(): void { } + public clear(): void { } + /** * Called when we start drawing a new frame. * diff --git a/src/browser/renderer/atlas/DynamicCharAtlas.ts b/src/browser/renderer/atlas/DynamicCharAtlas.ts index a72378785..666324ad5 100644 --- a/src/browser/renderer/atlas/DynamicCharAtlas.ts +++ b/src/browser/renderer/atlas/DynamicCharAtlas.ts @@ -119,6 +119,16 @@ export class DynamicCharAtlas extends BaseCharAtlas { this._drawToCacheCount = 0; } + public clear(): void { + if (this._cacheMap.size > 0) { + const capacity = this._width * this._height; + this._cacheMap = new LRUMap(capacity); + this._cacheMap.prealloc(capacity); + } + this._cacheCtx.clearRect(0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT); + this._tmpCtx.clearRect(0, 0, this._config.scaledCharWidth, this._config.scaledCharHeight); + } + public draw( ctx: CanvasRenderingContext2D, glyph: IGlyphIdentifier, diff --git a/src/browser/services/RenderService.ts b/src/browser/services/RenderService.ts index 332e71dae..b8283e0e6 100644 --- a/src/browser/services/RenderService.ts +++ b/src/browser/services/RenderService.ts @@ -168,6 +168,11 @@ export class RenderService extends Disposable implements IRenderService { } } + public clearTextureAtlas(): void { + this._renderer?.clearTextureAtlas?.(); + this._fullRefresh(); + } + public setColors(colors: IColorSet): void { this._renderer.setColors(colors); this._fullRefresh(); diff --git a/src/browser/services/Services.ts b/src/browser/services/Services.ts index 8c8a7bd9b..4928fa28e 100644 --- a/src/browser/services/Services.ts +++ b/src/browser/services/Services.ts @@ -53,6 +53,7 @@ export interface IRenderService extends IDisposable { dimensions: IRenderDimensions; refreshRows(start: number, end: number): void; + clearTextureAtlas(): void; resize(cols: number, rows: number): void; changeOptions(): void; setRenderer(renderer: IRenderer): void; diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index ba2be9881..66d45f321 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -1056,6 +1056,14 @@ declare module 'xterm' { */ refresh(start: number, end: number): void; + /** + * Clears the texture atlas of the canvas renderer if it's active. Doing this will force a + * redraw of all glyphs which can workaround issues causing the texture to become corrupt, for + * example Chromium/Nvidia has an issue where the texture gets messed up when resuming the OS + * from sleep. + */ + clearTextureAtlas(): void; + /** * Perform a full reset (RIS, aka '\x1bc'). */ From 3a71b3f11e9781e0df834bafdf8c51a007b06920 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 22 Sep 2021 14:21:50 -0700 Subject: [PATCH 158/164] Add document role to accessibility tree root See microsoft/vscode#98918 --- src/browser/AccessibilityManager.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/browser/AccessibilityManager.ts b/src/browser/AccessibilityManager.ts index 1be3342d7..800922022 100644 --- a/src/browser/AccessibilityManager.ts +++ b/src/browser/AccessibilityManager.ts @@ -53,6 +53,7 @@ export class AccessibilityManager extends Disposable { ) { super(); this._accessibilityTreeRoot = document.createElement('div'); + this._accessibilityTreeRoot.setAttribute('role', 'document'); this._accessibilityTreeRoot.classList.add('xterm-accessibility'); this._rowContainer = document.createElement('div'); From 014530f58216e58b1aeae6757357c3de01eff919 Mon Sep 17 00:00:00 2001 From: "mac.bae" Date: Thu, 7 Oct 2021 07:44:30 +0000 Subject: [PATCH 159/164] Added goormIDE on Real-world uses --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 720e703cf..e6d8f9a9a 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,7 @@ Xterm.js is used in several world-class applications to provide great terminal e - [**HashiCorp Nomad**](https://www.nomadproject.io/): A container orchestrator with the ability to connect to remote tasks via a web interface using websockets and xterm.js. - [**TermPair**](https://github.com/cs01/termpair): View and control terminals from your browser with end-to-end encryption - [**gdbgui**](https://github.com/cs01/gdbgui): Browser-based frontend to gdb (gnu debugger) +- [**goormIDE**](https://ide.goorm.io/): Run almost every programming languages with real-time collaboration, live pair programming, and built-in messenger. - [And much more...](https://github.com/xtermjs/xterm.js/network/dependents) Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it on our list. Note: Please add any new contributions to the end of the list only. From 37a4100220ed19e003b39e4c3c23acbfe207fea1 Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Fri, 8 Oct 2021 07:45:48 -0700 Subject: [PATCH 160/164] throw if activate webgl called on safari --- addons/xterm-addon-webgl/src/WebglAddon.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/xterm-addon-webgl/src/WebglAddon.ts b/addons/xterm-addon-webgl/src/WebglAddon.ts index ad2393d83..b8bcf5b1d 100644 --- a/addons/xterm-addon-webgl/src/WebglAddon.ts +++ b/addons/xterm-addon-webgl/src/WebglAddon.ts @@ -8,6 +8,7 @@ import { WebglRenderer } from './WebglRenderer'; import { ICharacterJoinerService, IRenderService } from 'browser/services/Services'; import { IColorSet } from 'browser/Types'; import { EventEmitter } from 'common/EventEmitter'; +import { isSafari } from 'common/Platform'; export class WebglAddon implements ITerminalAddon { private _terminal?: Terminal; @@ -23,6 +24,9 @@ export class WebglAddon implements ITerminalAddon { if (!terminal.element) { throw new Error('Cannot activate WebglAddon before Terminal.open'); } + if (isSafari) { + throw new Error('Webgl is not currently supported on Safari'); + } this._terminal = terminal; const renderService: IRenderService = (terminal as any)._core._renderService; const characterJoinerService: ICharacterJoinerService = (terminal as any)._core._characterJoinerService; From 0c604789530ff416ed88ccec61eee126c5843bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Sun, 10 Oct 2021 19:36:20 +0200 Subject: [PATCH 161/164] fix DECTCEM in DOM renderer --- .../dom/DomRendererRowFactory.test.ts | 56 ++++++++++--------- .../renderer/dom/DomRendererRowFactory.ts | 7 ++- 2 files changed, 35 insertions(+), 28 deletions(-) diff --git a/src/browser/renderer/dom/DomRendererRowFactory.test.ts b/src/browser/renderer/dom/DomRendererRowFactory.test.ts index 2f8d264a5..f41e5d44c 100644 --- a/src/browser/renderer/dom/DomRendererRowFactory.test.ts +++ b/src/browser/renderer/dom/DomRendererRowFactory.test.ts @@ -10,7 +10,7 @@ import { NULL_CELL_CODE, NULL_CELL_WIDTH, NULL_CELL_CHAR, DEFAULT_ATTR, FgFlags, import { BufferLine, DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; import { IBufferLine } from 'common/Types'; import { CellData } from 'common/buffer/CellData'; -import { MockOptionsService } from 'common/TestUtils.test'; +import { MockCoreService, MockOptionsService } from 'common/TestUtils.test'; import { css } from 'browser/Color'; import { MockCharacterJoinerService } from 'browser/TestUtils.test'; @@ -21,30 +21,36 @@ describe('DomRendererRowFactory', () => { beforeEach(() => { dom = new jsdom.JSDOM(''); - rowFactory = new DomRendererRowFactory(dom.window.document, { - background: css.toColor('#010101'), - foreground: css.toColor('#020202'), - ansi: [ - // dark: - css.toColor('#2e3436'), - css.toColor('#cc0000'), - css.toColor('#4e9a06'), - css.toColor('#c4a000'), - css.toColor('#3465a4'), - css.toColor('#75507b'), - css.toColor('#06989a'), - css.toColor('#d3d7cf'), - // bright: - css.toColor('#555753'), - css.toColor('#ef2929'), - css.toColor('#8ae234'), - css.toColor('#fce94f'), - css.toColor('#729fcf'), - css.toColor('#ad7fa8'), - css.toColor('#34e2e2'), - css.toColor('#eeeeec') - ] - } as any, new MockCharacterJoinerService(), new MockOptionsService({ drawBoldTextInBrightColors: true })); + rowFactory = new DomRendererRowFactory( + dom.window.document, + { + background: css.toColor('#010101'), + foreground: css.toColor('#020202'), + ansi: [ + // dark: + css.toColor('#2e3436'), + css.toColor('#cc0000'), + css.toColor('#4e9a06'), + css.toColor('#c4a000'), + css.toColor('#3465a4'), + css.toColor('#75507b'), + css.toColor('#06989a'), + css.toColor('#d3d7cf'), + // bright: + css.toColor('#555753'), + css.toColor('#ef2929'), + css.toColor('#8ae234'), + css.toColor('#fce94f'), + css.toColor('#729fcf'), + css.toColor('#ad7fa8'), + css.toColor('#34e2e2'), + css.toColor('#eeeeec') + ] + } as any, + new MockCharacterJoinerService(), + new MockOptionsService({ drawBoldTextInBrightColors: true }), + new MockCoreService() + ); lineData = createEmptyLineData(2); }); diff --git a/src/browser/renderer/dom/DomRendererRowFactory.ts b/src/browser/renderer/dom/DomRendererRowFactory.ts index a61ebd739..a24f3e463 100644 --- a/src/browser/renderer/dom/DomRendererRowFactory.ts +++ b/src/browser/renderer/dom/DomRendererRowFactory.ts @@ -7,7 +7,7 @@ import { IBufferLine } from 'common/Types'; import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants'; import { NULL_CELL_CODE, WHITESPACE_CELL_CHAR, Attributes } from 'common/buffer/Constants'; import { CellData } from 'common/buffer/CellData'; -import { IOptionsService } from 'common/services/Services'; +import { ICoreService, IOptionsService } from 'common/services/Services'; import { color, rgba } from 'browser/Color'; import { IColorSet, IColor } from 'browser/Types'; import { ICharacterJoinerService } from 'browser/services/Services'; @@ -31,7 +31,8 @@ export class DomRendererRowFactory { private readonly _document: Document, private _colors: IColorSet, @ICharacterJoinerService private readonly _characterJoinerService: ICharacterJoinerService, - @IOptionsService private readonly _optionsService: IOptionsService + @IOptionsService private readonly _optionsService: IOptionsService, + @ICoreService private readonly _coreService: ICoreService ) { } @@ -110,7 +111,7 @@ export class DomRendererRowFactory { } } - if (isCursorRow && x === cursorX) { + if (!this._coreService.isCursorHidden && isCursorRow && x === cursorX) { charElement.classList.add(CURSOR_CLASS); if (cursorBlink) { From 5d5f34f65f8ffd9469d6ced1738ebc7d27d68485 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 12 Oct 2021 09:05:44 -0700 Subject: [PATCH 162/164] Report focus state on DECSET 1004 Fixes #2333 --- src/browser/Terminal.ts | 9 +++++++++ src/common/InputHandler.ts | 3 +++ 2 files changed, 12 insertions(+) diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index dde4a1b6e..513fdf62f 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -150,6 +150,7 @@ export class Terminal extends CoreTerminal implements ITerminal { // Setup InputHandler listeners this.register(this._inputHandler.onRequestBell(() => this.bell())); this.register(this._inputHandler.onRequestRefreshRows((start, end) => this.refresh(start, end))); + this.register(this._inputHandler.onRequestSendFocus(() => this._reportFocus())); this.register(this._inputHandler.onRequestReset(() => this.reset())); this.register(this._inputHandler.onRequestWindowsOptionsReport(type => this._reportWindowsOptions(type))); this.register(this._inputHandler.onAnsiColorChange((event) => this._changeAnsiColor(event))); @@ -1238,6 +1239,14 @@ export class Terminal extends CoreTerminal implements ITerminal { this.viewport?.syncScrollArea(); } + private _reportFocus(): void { + if (this.element?.classList.contains('focus')) { + this.coreService.triggerDataEvent(C0.ESC + '[I'); + } else { + this.coreService.triggerDataEvent(C0.ESC + '[O'); + } + } + private _reportWindowsOptions(type: WindowsOptionsReportType): void { if (!this._renderService) { return; diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index d4354e90a..0f91a0114 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -240,6 +240,8 @@ export class InputHandler extends Disposable implements IInputHandler { public get onRequestRefreshRows(): IEvent { return this._onRequestRefreshRows.event; } private _onRequestReset = new EventEmitter(); public get onRequestReset(): IEvent { return this._onRequestReset.event; } + private _onRequestSendFocus = new EventEmitter(); + public get onRequestSendFocus(): IEvent { return this._onRequestSendFocus.event; } private _onRequestSyncScrollBar = new EventEmitter(); public get onRequestSyncScrollBar(): IEvent { return this._onRequestSyncScrollBar.event; } private _onRequestWindowsOptionsReport = new EventEmitter(); @@ -1976,6 +1978,7 @@ export class InputHandler extends Disposable implements IInputHandler { // focusin: ^[[I // focusout: ^[[O this._coreService.decPrivateModes.sendFocus = true; + this._onRequestSendFocus.fire(); break; case 1005: // utf8 ext mode mouse - removed in #2507 this._logService.debug('DECSET 1005 not supported (see #2507)'); From 581272ee51129ee2431718b03e90755aed63d8ba Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 19 Oct 2021 10:28:09 -0700 Subject: [PATCH 163/164] Swallow error when opener can't be sent Fixes #2943 Co-authored-by: Megan Rogge --- addons/xterm-addon-web-links/src/WebLinksAddon.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/xterm-addon-web-links/src/WebLinksAddon.ts b/addons/xterm-addon-web-links/src/WebLinksAddon.ts index 46ddcf7b2..dd1c1f174 100644 --- a/addons/xterm-addon-web-links/src/WebLinksAddon.ts +++ b/addons/xterm-addon-web-links/src/WebLinksAddon.ts @@ -29,7 +29,11 @@ const strictUrlRegex = new RegExp(start + protocolClause + bodyClause + end); function handleLink(event: MouseEvent, uri: string): void { const newWindow = window.open(); if (newWindow) { - newWindow.opener = null; + try { + newWindow.opener = null; + } catch { + // no-op, Electron can throw + } newWindow.location.href = uri; } else { console.warn('Opening link blocked as opener could not be cleared'); From 472e410205fb622f617ad8d70fa2c35e5106bb95 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 19 Oct 2021 10:49:01 -0700 Subject: [PATCH 164/164] Call out deserialize into same size terminal Fixes #3093 Co-authored-by: Megan Rogge --- .../xterm-addon-serialize/typings/xterm-addon-serialize.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts b/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts index b55ee303d..23290af49 100644 --- a/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts +++ b/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts @@ -24,6 +24,10 @@ declare module 'xterm-addon-serialize' { * the state. The cursor will also be positioned to the correct cell. When restoring a terminal * it is best to do before `Terminal.open` is called to avoid wasting CPU cycles rendering * incomplete frames. + * + * It's recommended that you write the serialized data into a terminal of the same size in which + * it originated from and then resize it after if needed. + * * @param scrollback The number of rows in scrollback buffer to serialize, starting from the * bottom of the scrollback buffer. This defaults to the all available rows in the scrollback * buffer.