mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Fix rename clipboard selection for clarity
This commit is contained in:
@@ -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<string> {
|
||||
public readText(selection: ClipboardSelectionType): Promise<string> {
|
||||
if (selection !== 'c') {
|
||||
return Promise.resolve('');
|
||||
}
|
||||
return navigator.clipboard.readText().then((text) =>
|
||||
Base64.encode(text));
|
||||
}
|
||||
public writeText(selection: ClipboardSelection, data: string): Promise<void> {
|
||||
public writeText(selection: ClipboardSelectionType, data: string): Promise<void> {
|
||||
if (selection !== 'c' || (this.limit > 0 && data.length > this.limit)) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@@ -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<string>;
|
||||
public writeText(selection: ClipboardSelection, data: string): Promise<void>;
|
||||
public readText(selection: ClipboardSelectionType): Promise<string>;
|
||||
public writeText(selection: ClipboardSelectionType, data: string): Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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: '?'
|
||||
}
|
||||
]);
|
||||
|
||||
@@ -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,
|
||||
|
||||
Vendored
+2
-2
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+3
-3
@@ -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<string>;
|
||||
readText(selection: ClipboardSelectionType): Promise<string>;
|
||||
|
||||
/**
|
||||
* 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<void>;
|
||||
writeText(selection: ClipboardSelectionType, data: string): Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user