mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Move more handlers out, addon types into shared file
This commit is contained in:
+3
-40
@@ -37,7 +37,7 @@ import { WebglAddon } from '@xterm/addon-webgl';
|
||||
import { Unicode11Addon } from '@xterm/addon-unicode11';
|
||||
import { UnicodeGraphemesAddon } from '@xterm/addon-unicode-graphemes';
|
||||
|
||||
import { writeUnicodeTable } from './unicodeTable';
|
||||
import { AddonCollection, type AddonType, type IDemoAddon } from './types';
|
||||
|
||||
export interface IWindowWithTerminal extends Window {
|
||||
term: typeof Terminal;
|
||||
@@ -69,44 +69,7 @@ let optionsWindow: OptionsWindow;
|
||||
let styleWindow: StyleWindow;
|
||||
let vtWindow: VtWindow;
|
||||
|
||||
type AddonType = 'attach' | 'clipboard' | 'fit' | 'image' | 'progress' | 'search' | 'serialize' | 'unicode11' | 'unicodeGraphemes' | 'webLinks' | 'webgl' | 'ligatures';
|
||||
|
||||
interface IDemoAddon<T extends AddonType> {
|
||||
name: T;
|
||||
canChange: boolean;
|
||||
ctor: (
|
||||
T extends 'attach' ? typeof AttachAddon :
|
||||
T extends 'clipboard' ? typeof ClipboardAddon :
|
||||
T extends 'fit' ? typeof FitAddon :
|
||||
T extends 'image' ? typeof ImageAddonType :
|
||||
T extends 'ligatures' ? typeof LigaturesAddon :
|
||||
T extends 'progress' ? typeof ProgressAddon :
|
||||
T extends 'search' ? typeof SearchAddon :
|
||||
T extends 'serialize' ? typeof SerializeAddon :
|
||||
T extends 'webLinks' ? typeof WebLinksAddon :
|
||||
T extends 'unicode11' ? typeof Unicode11Addon :
|
||||
T extends 'unicodeGraphemes' ? typeof UnicodeGraphemesAddon :
|
||||
T extends 'webgl' ? typeof WebglAddon :
|
||||
never
|
||||
);
|
||||
instance?: (
|
||||
T extends 'attach' ? AttachAddon :
|
||||
T extends 'clipboard' ? ClipboardAddon :
|
||||
T extends 'fit' ? FitAddon :
|
||||
T extends 'image' ? ImageAddonType :
|
||||
T extends 'ligatures' ? LigaturesAddon :
|
||||
T extends 'progress' ? ProgressAddon :
|
||||
T extends 'search' ? SearchAddon :
|
||||
T extends 'serialize' ? SerializeAddon :
|
||||
T extends 'webLinks' ? WebLinksAddon :
|
||||
T extends 'unicode11' ? Unicode11Addon :
|
||||
T extends 'unicodeGraphemes' ? UnicodeGraphemesAddon :
|
||||
T extends 'webgl' ? WebglAddon :
|
||||
never
|
||||
);
|
||||
}
|
||||
|
||||
const addons: { [T in AddonType]: IDemoAddon<T> } = {
|
||||
const addons: AddonCollection = {
|
||||
attach: { name: 'attach', ctor: AttachAddon, canChange: false },
|
||||
clipboard: { name: 'clipboard', ctor: ClipboardAddon, canChange: true },
|
||||
fit: { name: 'fit', ctor: FitAddon, canChange: false },
|
||||
@@ -257,7 +220,7 @@ if (document.location.pathname === '/test') {
|
||||
const styleWindow = controlBar.registerWindow(new StyleWindow());
|
||||
paddingElement = styleWindow.paddingElement;
|
||||
controlBar.registerWindow(optionsWindow);
|
||||
controlBar.registerWindow(new TestWindow(typedTerm));
|
||||
controlBar.registerWindow(new TestWindow(typedTerm, addons));
|
||||
vtWindow = new VtWindow();
|
||||
controlBar.registerWindow(vtWindow);
|
||||
vtWindow.initTerminal(term);
|
||||
|
||||
@@ -8,14 +8,16 @@
|
||||
import { writeUnicodeTable } from 'unicodeTable';
|
||||
import type { IControlWindow } from '../controlBar';
|
||||
import type { Terminal } from '@xterm/xterm';
|
||||
import type { AddonCollection } from 'types';
|
||||
|
||||
export class TestWindow implements IControlWindow {
|
||||
public readonly id = 'test';
|
||||
public readonly label = 'Test';
|
||||
|
||||
private _printCjkButton: HTMLButtonElement;
|
||||
|
||||
constructor(private readonly _terminal: Terminal) {
|
||||
constructor(
|
||||
private readonly _terminal: Terminal,
|
||||
private readonly _addons: AddonCollection
|
||||
) {
|
||||
}
|
||||
|
||||
public build(container: HTMLElement): void {
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
|
||||
* @license MIT
|
||||
*
|
||||
* This file is the entry point for browserify.
|
||||
*/
|
||||
|
||||
import type { ImageAddon } from '@xterm/addon-image';
|
||||
import type { AttachAddon } from '@xterm/addon-attach';
|
||||
import type { ClipboardAddon } from '@xterm/addon-clipboard';
|
||||
import type { FitAddon } from '@xterm/addon-fit';
|
||||
import type { LigaturesAddon } from '@xterm/addon-ligatures';
|
||||
import type { ProgressAddon } from '@xterm/addon-progress';
|
||||
import type { SearchAddon } from '@xterm/addon-search';
|
||||
import type { SerializeAddon } from '@xterm/addon-serialize';
|
||||
import type { UnicodeGraphemesAddon } from '@xterm/addon-unicode-graphemes';
|
||||
import type { Unicode11Addon } from '@xterm/addon-unicode11';
|
||||
import type { WebLinksAddon } from '@xterm/addon-web-links';
|
||||
import type { WebglAddon } from '@xterm/addon-webgl';
|
||||
|
||||
export type AddonType = 'attach' | 'clipboard' | 'fit' | 'image' | 'progress' | 'search' | 'serialize' | 'unicode11' | 'unicodeGraphemes' | 'webLinks' | 'webgl' | 'ligatures';
|
||||
|
||||
export interface IDemoAddon<T extends AddonType> {
|
||||
name: T;
|
||||
canChange: boolean;
|
||||
ctor: (
|
||||
T extends 'attach' ? typeof AttachAddon :
|
||||
T extends 'clipboard' ? typeof ClipboardAddon :
|
||||
T extends 'fit' ? typeof FitAddon :
|
||||
T extends 'image' ? typeof ImageAddon :
|
||||
T extends 'ligatures' ? typeof LigaturesAddon :
|
||||
T extends 'progress' ? typeof ProgressAddon :
|
||||
T extends 'search' ? typeof SearchAddon :
|
||||
T extends 'serialize' ? typeof SerializeAddon :
|
||||
T extends 'webLinks' ? typeof WebLinksAddon :
|
||||
T extends 'unicode11' ? typeof Unicode11Addon :
|
||||
T extends 'unicodeGraphemes' ? typeof UnicodeGraphemesAddon :
|
||||
T extends 'webgl' ? typeof WebglAddon :
|
||||
never
|
||||
);
|
||||
instance?: (
|
||||
T extends 'attach' ? AttachAddon :
|
||||
T extends 'clipboard' ? ClipboardAddon :
|
||||
T extends 'fit' ? FitAddon :
|
||||
T extends 'image' ? ImageAddon :
|
||||
T extends 'ligatures' ? LigaturesAddon :
|
||||
T extends 'progress' ? ProgressAddon :
|
||||
T extends 'search' ? SearchAddon :
|
||||
T extends 'serialize' ? SerializeAddon :
|
||||
T extends 'webLinks' ? WebLinksAddon :
|
||||
T extends 'unicode11' ? Unicode11Addon :
|
||||
T extends 'unicodeGraphemes' ? UnicodeGraphemesAddon :
|
||||
T extends 'webgl' ? WebglAddon :
|
||||
never
|
||||
);
|
||||
}
|
||||
|
||||
export type AddonCollection = { [T in AddonType]: IDemoAddon<T> };
|
||||
Reference in New Issue
Block a user