mirror of
https://github.com/yudai/gotty.git
synced 2026-01-08 18:48:50 +01:00
Add WebGL and links addons for xterm.js
This commit is contained in:
parent
8d7358b3b3
commit
0dfc5aed76
9 changed files with 47 additions and 14 deletions
|
|
@ -53,7 +53,9 @@ export class Hterm {
|
|||
|
||||
setPreferences(value: object) {
|
||||
Object.keys(value).forEach((key) => {
|
||||
this.term.getPrefs().set(key, value[key]);
|
||||
if (key != "EnableWebGL") {
|
||||
this.term.getPrefs().set(key, value[key]);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -75,9 +77,9 @@ export class Hterm {
|
|||
};
|
||||
|
||||
deactivate(): void {
|
||||
this.io.onVTKeystroke = function(){};
|
||||
this.io.sendString = function(){};
|
||||
this.io.onTerminalResize = function(){};
|
||||
this.io.onVTKeystroke = function () { };
|
||||
this.io.sendString = function () { };
|
||||
this.io.onTerminalResize = function () { };
|
||||
this.term.uninstallKeyboard();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import { Terminal, IDisposable } from "xterm";
|
||||
import { FitAddon } from 'xterm-addon-fit';
|
||||
import { WebLinksAddon } from 'xterm-addon-web-links';
|
||||
import { WebglAddon } from 'xterm-addon-webgl';
|
||||
import { lib } from "libapps"
|
||||
|
||||
export class Xterm {
|
||||
|
|
@ -13,19 +15,21 @@ export class Xterm {
|
|||
messageTimer: NodeJS.Timeout;
|
||||
onResizeHandler: IDisposable;
|
||||
onDataHandler: IDisposable;
|
||||
fitAddOn: FitAddon;
|
||||
|
||||
constructor(elem: HTMLElement) {
|
||||
this.elem = elem;
|
||||
this.term = new Terminal();
|
||||
const fitAddon = new FitAddon();
|
||||
this.term.loadAddon(fitAddon);
|
||||
this.fitAddOn = new FitAddon();
|
||||
this.term.loadAddon(new WebLinksAddon());
|
||||
this.term.loadAddon(this.fitAddOn);
|
||||
|
||||
this.message = elem.ownerDocument.createElement("div");
|
||||
this.message.className = "xterm-overlay";
|
||||
this.messageTimeout = 2000;
|
||||
|
||||
this.resizeListener = () => {
|
||||
fitAddon.fit();
|
||||
this.fitAddOn.fit();
|
||||
this.term.scrollToBottom();
|
||||
this.showMessage(String(this.term.cols) + "x" + String(this.term.rows), this.messageTimeout);
|
||||
};
|
||||
|
|
@ -71,6 +75,11 @@ export class Xterm {
|
|||
};
|
||||
|
||||
setPreferences(value: object) {
|
||||
Object.keys(value).forEach((key) => {
|
||||
if (key == "EnableWebGL" && key) {
|
||||
this.term.loadAddon(new WebglAddon());
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
onInput(callback: (input: string) => void) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue