From 157055c03ba861d9b5a5153b19aa21039c1d08b1 Mon Sep 17 00:00:00 2001 From: joyceerhl Date: Sun, 10 Jan 2021 00:14:29 -0800 Subject: [PATCH 001/105] 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/105] 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/105] 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 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 004/105] 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 005/105] 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 006/105] 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 007/105] 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 008/105] 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 009/105] 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 010/105] 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 011/105] 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 012/105] 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 013/105] 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 12e1e422e301cad2f21006d4720883f6818f2a7f Mon Sep 17 00:00:00 2001 From: Samuel Sampson Date: Thu, 29 Jul 2021 19:35:14 +0000 Subject: [PATCH 014/105] 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 015/105] 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 016/105] 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 017/105] 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 018/105] 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 019/105] 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 020/105] 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 021/105] 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 022/105] 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 023/105] 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 024/105] 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 025/105] 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 026/105] 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 027/105] 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 028/105] 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 029/105] 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 030/105] 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 031/105] 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 032/105] 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 033/105] 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 034/105] 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 035/105] 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 036/105] 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 037/105] 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 038/105] 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 039/105] 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 040/105] 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 041/105] 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 042/105] 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 043/105] 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 044/105] 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 045/105] 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 046/105] 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 047/105] 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 048/105] 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 049/105] 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 050/105] 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 051/105] 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 052/105] 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 053/105] 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 054/105] 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 055/105] 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 056/105] 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 057/105] 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 058/105] 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 059/105] 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 060/105] 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 061/105] 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 062/105] 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 063/105] 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 064/105] 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 065/105] 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 066/105] 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 067/105] 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 068/105] 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 069/105] 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 070/105] 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 071/105] 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 072/105] 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 073/105] 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 074/105] 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 075/105] 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 076/105] 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 077/105] 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 078/105] 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 079/105] 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 080/105] 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 081/105] 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 082/105] 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 083/105] 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 084/105] 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 085/105] 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 086/105] 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 087/105] 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 088/105] 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 089/105] 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 090/105] 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 091/105] 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 092/105] 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 093/105] 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 094/105] 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 095/105] 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 096/105] 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 097/105] 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 098/105] 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 099/105] 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 100/105] 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 101/105] 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 102/105] 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 103/105] 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 104/105] 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 105/105] 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; }