';
- Object.keys(stringOptions).forEach(o => {
- if (o === 'colsRows') {
- html += `
`;
- } else if (stringOptions[o]) {
- const selectedOption = o === 'theme' ? 'xtermjs' : term.options[o];
- html += `
`;
- } else {
- html += `
`;
- }
- });
- html += '
';
-
- const container = document.getElementById('options-container');
- container.innerHTML = html;
-
- // Attach listeners
- booleanOptions.forEach(o => {
- const input = document.getElementById(`opt-${o}`) as HTMLInputElement;
- addDomListener(input, 'change', () => {
- console.log('change', o, input.checked);
- term.options[o] = input.checked;
- });
- });
- numberOptions.forEach(o => {
- const input = document.getElementById(`opt-${o}`) as HTMLInputElement;
- addDomListener(input, 'change', () => {
- console.log('change', o, input.value);
- if (o === 'lineHeight') {
- term.options.lineHeight = parseFloat(input.value);
- } else if (o === 'scrollSensitivity') {
- term.options.scrollSensitivity = parseFloat(input.value);
- } else if (o === 'scrollback') {
- term.options.scrollback = parseInt(input.value);
- setTimeout(() => updateTerminalSize(), 5);
- } else {
- term.options[o] = parseInt(input.value);
- }
- // Always update terminal size in case the option changes the dimensions
- updateTerminalSize();
- });
- });
- Object.keys(stringOptions).forEach(o => {
- const input = document.getElementById(`opt-${o}`) as HTMLInputElement;
- addDomListener(input, 'change', () => {
- console.log('change', o, input.value);
- let value: any = input.value;
- if (o === 'colsRows') {
- const m = input.value.match(/^([0-9]+)x([0-9]+)$/);
- if (m) {
- autoResize = false;
- term.resize(parseInt(m[1]), parseInt(m[2]));
- } else {
- autoResize = true;
- input.value = 'auto';
- updateTerminalSize();
- }
- } else if (o === 'theme') {
- switch (input.value) {
- case 'default':
- value = undefined;
- break;
- case 'xtermjs':
- // Custom theme to match style of xterm.js logo
- value = xtermjsTheme;
- case 'sapphire':
- // Color source: https://github.com/Tyriar/vscode-theme-sapphire
- value = {
- background: '#1c2431',
- foreground: '#cccccc',
- selectionBackground: '#399ef440',
- black: '#666666',
- blue: '#399ef4',
- brightBlack: '#666666',
- brightBlue: '#399ef4',
- brightCyan: '#21c5c7',
- brightGreen: '#4eb071',
- brightMagenta: '#b168df',
- brightRed: '#da6771',
- brightWhite: '#efefef',
- brightYellow: '#fff099',
- cyan: '#21c5c7',
- green: '#4eb071',
- magenta: '#b168df',
- red: '#da6771',
- white: '#efefef',
- yellow: '#fff099'
- };
- break;
- case 'light':
- // Color source: https://github.com/microsoft/vscode/blob/main/extensions/theme-defaults/themes/light_plus.json
- value = {
- background: '#ffffff',
- foreground: '#333333',
- cursor: '#333333',
- cursorAccent: '#ffffff',
- selectionBackground: '#add6ff',
- overviewRulerBorder: '#aaaaaa',
- black: '#000000',
- blue: '#0451a5',
- brightBlack: '#666666',
- brightBlue: '#0451a5',
- brightCyan: '#0598bc',
- brightGreen: '#14ce14',
- brightMagenta: '#bc05bc',
- brightRed: '#cd3131',
- brightWhite: '#a5a5a5',
- brightYellow: '#b5ba00',
- cyan: '#0598bc',
- green: '#00bc00',
- magenta: '#bc05bc',
- red: '#cd3131',
- white: '#555555',
- yellow: '#949800'
- };
- break;
- }
- }
- term.options[o] = value;
- });
- });
-}
-
-function initAddons(term: Terminal): void {
- const fragment = document.createDocumentFragment();
- Object.keys(addons).forEach((name: AddonType) => {
- const addon = addons[name];
- const checkbox = document.createElement('input') as HTMLInputElement;
- checkbox.type = 'checkbox';
- checkbox.checked = !!addon.instance;
- if (!addon.canChange) {
- checkbox.disabled = true;
- }
- if (name === 'unicode11' && checkbox.checked) {
- term.unicode.activeVersion = '11';
- }
- if (name === 'unicodeGraphemes' && checkbox.checked) {
- term.unicode.activeVersion = '15-graphemes';
- }
- if (name === 'search' && checkbox.checked) {
- addons[name].instance.onDidChangeResults(e => updateFindResults(e));
- }
- addDomListener(checkbox, 'change', () => {
- if (name === 'image') {
- if (checkbox.checked) {
- const ctorOptionsJson = document.querySelector