diff --git a/addons/xterm-addon-clipboard/src/ClipboardProvider.ts b/addons/xterm-addon-clipboard/src/ClipboardProvider.ts index a28ef8d5..e7f9ff8a 100644 --- a/addons/xterm-addon-clipboard/src/ClipboardProvider.ts +++ b/addons/xterm-addon-clipboard/src/ClipboardProvider.ts @@ -4,7 +4,7 @@ */ import { Base64 } from 'js-base64'; -import { ClipboardSelection, IClipboardProvider } from 'xterm'; +import { ClipboardSelectionType, IClipboardProvider } from 'xterm'; export class ClipboardProvider implements IClipboardProvider { constructor( @@ -14,14 +14,14 @@ export class ClipboardProvider implements IClipboardProvider { */ public limit = 1000000 // 1MB ){} - public readText(selection: ClipboardSelection): Promise { + public readText(selection: ClipboardSelectionType): Promise { if (selection !== 'c') { return Promise.resolve(''); } return navigator.clipboard.readText().then((text) => Base64.encode(text)); } - public writeText(selection: ClipboardSelection, data: string): Promise { + public writeText(selection: ClipboardSelectionType, data: string): Promise { if (selection !== 'c' || (this.limit > 0 && data.length > this.limit)) { return Promise.resolve(); } diff --git a/addons/xterm-addon-clipboard/typings/xterm-addon-clipboard.d.ts b/addons/xterm-addon-clipboard/typings/xterm-addon-clipboard.d.ts index 71d4f20d..c64cf625 100644 --- a/addons/xterm-addon-clipboard/typings/xterm-addon-clipboard.d.ts +++ b/addons/xterm-addon-clipboard/typings/xterm-addon-clipboard.d.ts @@ -3,12 +3,12 @@ * @license MIT */ -import { Terminal, ITerminalAddon, IClipboardProvider, ClipboardSelection } from 'xterm'; +import { Terminal, ITerminalAddon, IClipboardProvider, ClipboardSelection as ClipboardSelectionType } from 'xterm'; declare module 'xterm-addon-clipboard' { export class ClipboardProvider implements IClipboardProvider{ - public readText(selection: ClipboardSelection): Promise; - public writeText(selection: ClipboardSelection, data: string): Promise; + public readText(selection: ClipboardSelectionType): Promise; + public writeText(selection: ClipboardSelectionType, data: string): Promise; } /** diff --git a/src/common/InputHandler.test.ts b/src/common/InputHandler.test.ts index 0ae912a5..f5bf1dde 100644 --- a/src/common/InputHandler.test.ts +++ b/src/common/InputHandler.test.ts @@ -17,7 +17,7 @@ import { DEFAULT_OPTIONS } from 'common/services/OptionsService'; import { clone } from 'common/Clone'; import { BufferService } from 'common/services/BufferService'; import { CoreService } from 'common/services/CoreService'; -import { ClipboardSelection } from 'xterm'; +import { ClipboardSelectionType } from 'xterm'; function getCursor(bufferService: IBufferService): number[] { return [ @@ -2003,62 +2003,62 @@ describe('InputHandler', () => { assert.deepEqual(stack, [ { type: ClipboardEventType.SET, - selection: ClipboardSelection.SYSTEM, + selection: ClipboardSelectionType.SYSTEM, data: '' }, { type: ClipboardEventType.SET, - selection: ClipboardSelection.SYSTEM, + selection: ClipboardSelectionType.SYSTEM, data: testDataRaw }, { type: ClipboardEventType.SET, - selection: ClipboardSelection.SYSTEM, + selection: ClipboardSelectionType.SYSTEM, data: testDataB64 }, { type: ClipboardEventType.SET, - selection: ClipboardSelection.SYSTEM, + selection: ClipboardSelectionType.SYSTEM, data: testDataB64+'invalid' }, { type: ClipboardEventType.SET, - selection: ClipboardSelection.SYSTEM, + selection: ClipboardSelectionType.SYSTEM, data: '!' }, { type: ClipboardEventType.REPORT, - selection: ClipboardSelection.SYSTEM, + selection: ClipboardSelectionType.SYSTEM, data: '?' }, { type: ClipboardEventType.SET, - selection: ClipboardSelection.PRIMARY, + selection: ClipboardSelectionType.PRIMARY, data: '' }, { type: ClipboardEventType.SET, - selection: ClipboardSelection.PRIMARY, + selection: ClipboardSelectionType.PRIMARY, data: testDataRaw }, { type: ClipboardEventType.SET, - selection: ClipboardSelection.PRIMARY, + selection: ClipboardSelectionType.PRIMARY, data: testDataB64 }, { type: ClipboardEventType.SET, - selection: ClipboardSelection.PRIMARY, + selection: ClipboardSelectionType.PRIMARY, data: testDataB64+'invalid' }, { type: ClipboardEventType.SET, - selection: ClipboardSelection.PRIMARY, + selection: ClipboardSelectionType.PRIMARY, data: '!' }, { type: ClipboardEventType.REPORT, - selection: ClipboardSelection.PRIMARY, + selection: ClipboardSelectionType.PRIMARY, data: '?' } ]); diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index cb46bccf..7fd5ad24 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -22,7 +22,7 @@ import { OscHandler } from 'common/parser/OscParser'; import { DcsHandler } from 'common/parser/DcsParser'; import { IBuffer } from 'common/buffer/Types'; import { parseColor } from 'common/input/XParseColor'; -import { ClipboardSelection } from 'xterm'; +import { ClipboardSelectionType } from 'xterm'; /** * Map collect to glevel. Used in `selectCharset`. @@ -3099,8 +3099,8 @@ export class InputHandler extends Disposable implements IInputHandler { return true; } switch (pc) { - case ClipboardSelection.SYSTEM: - case ClipboardSelection.PRIMARY: + case ClipboardSelectionType.SYSTEM: + case ClipboardSelectionType.PRIMARY: this._onClipboard.fire({ type: pd === '?' ? ClipboardEventType.REPORT : ClipboardEventType.SET, selection: pc, diff --git a/src/common/Types.d.ts b/src/common/Types.d.ts index 9146bb67..accd6243 100644 --- a/src/common/Types.d.ts +++ b/src/common/Types.d.ts @@ -9,7 +9,7 @@ import { Attributes, UnderlineStyle } from 'common/buffer/Constants'; // eslint- import { IBufferSet } from 'common/buffer/Types'; import { IParams } from 'common/parser/Types'; import { ICoreMouseService, ICoreService, IOptionsService, IUnicodeService } from 'common/services/Services'; -import { ClipboardSelection as ClipboardSelection, IFunctionIdentifier, ITerminalOptions as IPublicTerminalOptions } from 'xterm'; +import { ClipboardSelectionType as ClipboardSelectionType, IFunctionIdentifier, ITerminalOptions as IPublicTerminalOptions } from 'xterm'; export interface ICoreTerminal { coreMouseService: ICoreMouseService; @@ -452,7 +452,7 @@ export const enum ClipboardEventType { export interface IClipboardEvent { type: ClipboardEventType; - selection: ClipboardSelection; + selection: ClipboardSelectionType; data: string; } diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 0ab9071a..ba5b1630 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -1863,7 +1863,7 @@ declare module 'xterm' { * @param selection The clipboard selection to read. * @returns A promise that resolves with the base64 encoded data. */ - readText(selection: ClipboardSelection): Promise; + readText(selection: ClipboardSelectionType): Promise; /** * Sets the clipboard content. @@ -1871,7 +1871,7 @@ declare module 'xterm' { * @param data The base64 encoded data to set. If the data is invalid * base64, the clipboard is cleared. */ - writeText(selection: ClipboardSelection, data: string): Promise; + writeText(selection: ClipboardSelectionType, data: string): Promise; } /** @@ -1881,7 +1881,7 @@ declare module 'xterm' { * - PRIMARY `p`: The primary clipboard. This is provided for compatibility * with Linux X11. */ - export const enum ClipboardSelection { + export const enum ClipboardSelectionType { SYSTEM = 'c', PRIMARY = 'p', }