';
Object.keys(stringOptions).forEach(o => {
@@ -282,7 +312,7 @@ function initOptions(term: TerminalType): void {
console.log('change', o, input.value);
if (o === 'cols' || o === 'rows') {
updateTerminalSize();
- } else if (o === 'lineHeight') {
+ } else if (o === 'lineHeight' || o === 'scrollSensitivity') {
term.setOption(o, parseFloat(input.value));
updateTerminalSize();
} else {
@@ -299,6 +329,48 @@ function initOptions(term: TerminalType): void {
});
}
+function initAddons(term: TerminalType): 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;
+ }
+ checkbox.addEventListener('change', () => {
+ if (checkbox.checked) {
+ addon.instance = new addon.ctor();
+ term.loadAddon(addon.instance);
+ if (name === 'webgl') {
+ setTimeout(() => {
+ document.body.appendChild((addon.instance as WebglAddon).textureAtlas);
+ }, 0);
+ }
+ } else {
+ if (name === 'webgl') {
+ document.body.removeChild((addon.instance as WebglAddon).textureAtlas);
+ }
+ addon.instance!.dispose();
+ addon.instance = undefined;
+ }
+ });
+ const label = document.createElement('label');
+ label.classList.add('addon');
+ if (!addon.canChange) {
+ label.title = 'This addon is needed for the demo to operate';
+ }
+ label.appendChild(checkbox);
+ label.appendChild(document.createTextNode(name));
+ const wrapper = document.createElement('div');
+ wrapper.classList.add('addon');
+ wrapper.appendChild(label);
+ fragment.appendChild(wrapper);
+ });
+ document.getElementById('addons-container').appendChild(fragment);
+}
+
function addDomListener(element: HTMLElement, type: string, handler: (...args: any[]) => any): void {
element.addEventListener(type, handler);
term._core.register({ dispose: () => element.removeEventListener(type, handler) });
@@ -311,5 +383,5 @@ function updateTerminalSize(): void {
const height = (rows * term._core._renderService.dimensions.actualCellHeight).toString() + 'px';
terminalContainer.style.width = width;
terminalContainer.style.height = height;
- fitAddon.fit();
+ addons.fit.instance.fit();
}
diff --git a/demo/index.html b/demo/index.html
index ef8f3891c..88c6bc4c0 100644
--- a/demo/index.html
+++ b/demo/index.html
@@ -26,6 +26,11 @@
These options can be set in the Terminal constructor or using the Terminal.setOption function.
+