mirror of
https://github.com/sorenisanerd/gotty.git
synced 2024-11-22 04:14:25 +00:00
Update xterm.js 2.7.0 => 4.11.0
This commit is contained in:
parent
4a423fdf88
commit
65b49b18b3
4
Makefile
4
Makefile
@ -49,8 +49,8 @@ bindata/static/css/index.css: bindata/static/css resources/index.css
|
|||||||
bindata/static/css/xterm_customize.css: bindata/static/css resources/xterm_customize.css
|
bindata/static/css/xterm_customize.css: bindata/static/css resources/xterm_customize.css
|
||||||
cp resources/xterm_customize.css bindata/static/css/xterm_customize.css
|
cp resources/xterm_customize.css bindata/static/css/xterm_customize.css
|
||||||
|
|
||||||
bindata/static/css/xterm.css: bindata/static/css js/node_modules/xterm/dist/xterm.css
|
bindata/static/css/xterm.css: bindata/static/css js/node_modules/xterm/css/xterm.css
|
||||||
cp js/node_modules/xterm/dist/xterm.css bindata/static/css/xterm.css
|
cp js/node_modules/xterm/css/xterm.css bindata/static/css/xterm.css
|
||||||
|
|
||||||
js/node_modules/xterm/dist/xterm.css:
|
js/node_modules/xterm/dist/xterm.css:
|
||||||
cd js && \
|
cd js && \
|
||||||
|
11
js/package-lock.json
generated
11
js/package-lock.json
generated
@ -1453,9 +1453,14 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"xterm": {
|
"xterm": {
|
||||||
"version": "2.8.1",
|
"version": "4.11.0",
|
||||||
"resolved": "https://registry.npmjs.org/xterm/-/xterm-2.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/xterm/-/xterm-4.11.0.tgz",
|
||||||
"integrity": "sha512-AuqLOWpprmhSe4TcGE6Gh2uwkR0wUC95V0Q736OFUmG+84W+w+g6RzcgVhrbOTo/Fzcq9i0TRR5nYksRt2DSIQ=="
|
"integrity": "sha512-NeJH909WTO2vth/ZlC0gkP3AGzupbvVHVlmtrpBw56/sGFXaF9bNdKgqKa3tf8qbGvXMzL2JhCcHVklqFztIRw=="
|
||||||
|
},
|
||||||
|
"xterm-addon-fit": {
|
||||||
|
"version": "0.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/xterm-addon-fit/-/xterm-addon-fit-0.5.0.tgz",
|
||||||
|
"integrity": "sha512-DsS9fqhXHacEmsPxBJZvfj2la30Iz9xk+UKjhQgnYNkrUIN5CYLbw7WEfz117c7+S86S/tpHPfvNxJsF5/G8wQ=="
|
||||||
},
|
},
|
||||||
"yocto-queue": {
|
"yocto-queue": {
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
"css-loader": "^5.2.1",
|
"css-loader": "^5.2.1",
|
||||||
"libapps": "github:yudai/libapps#release-hterm-1.70",
|
"libapps": "github:yudai/libapps#release-hterm-1.70",
|
||||||
"style-loader": "^2.0.0",
|
"style-loader": "^2.0.0",
|
||||||
"xterm": "^2.7.0"
|
"xterm": "^4.11.0",
|
||||||
|
"xterm-addon-fit": "^0.5.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,40 +1,39 @@
|
|||||||
import * as bare from "xterm";
|
import { Terminal, IDisposable } from "xterm";
|
||||||
|
import { FitAddon } from 'xterm-addon-fit';
|
||||||
import { lib } from "libapps"
|
import { lib } from "libapps"
|
||||||
|
|
||||||
|
|
||||||
bare.loadAddon("fit");
|
|
||||||
|
|
||||||
export class Xterm {
|
export class Xterm {
|
||||||
elem: HTMLElement;
|
elem: HTMLElement;
|
||||||
term: bare;
|
term: Terminal;
|
||||||
resizeListener: () => void;
|
resizeListener: () => void;
|
||||||
decoder: lib.UTF8Decoder;
|
decoder: lib.UTF8Decoder;
|
||||||
|
|
||||||
message: HTMLElement;
|
message: HTMLElement;
|
||||||
messageTimeout: number;
|
messageTimeout: number;
|
||||||
messageTimer: NodeJS.Timeout;
|
messageTimer: NodeJS.Timeout;
|
||||||
|
onResizeHandler: IDisposable;
|
||||||
|
onDataHandler: IDisposable;
|
||||||
|
|
||||||
constructor(elem: HTMLElement) {
|
constructor(elem: HTMLElement) {
|
||||||
this.elem = elem;
|
this.elem = elem;
|
||||||
this.term = new bare();
|
this.term = new Terminal();
|
||||||
|
const fitAddon = new FitAddon();
|
||||||
|
this.term.loadAddon(fitAddon);
|
||||||
|
|
||||||
this.message = elem.ownerDocument.createElement("div");
|
this.message = elem.ownerDocument.createElement("div");
|
||||||
this.message.className = "xterm-overlay";
|
this.message.className = "xterm-overlay";
|
||||||
this.messageTimeout = 2000;
|
this.messageTimeout = 2000;
|
||||||
|
|
||||||
this.resizeListener = () => {
|
this.resizeListener = () => {
|
||||||
this.term.fit();
|
fitAddon.fit();
|
||||||
this.term.scrollToBottom();
|
this.term.scrollToBottom();
|
||||||
this.showMessage(String(this.term.cols) + "x" + String(this.term.rows), this.messageTimeout);
|
this.showMessage(String(this.term.cols) + "x" + String(this.term.rows), this.messageTimeout);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.term.on("open", () => {
|
this.term.open(elem);
|
||||||
this.resizeListener();
|
this.term.focus();
|
||||||
window.addEventListener("resize", () => { this.resizeListener(); });
|
this.resizeListener();
|
||||||
});
|
window.addEventListener("resize", () => { this.resizeListener(); });
|
||||||
|
|
||||||
this.term.open(elem, true);
|
|
||||||
|
|
||||||
this.decoder = new lib.UTF8Decoder()
|
this.decoder = new lib.UTF8Decoder()
|
||||||
};
|
};
|
||||||
@ -75,21 +74,21 @@ export class Xterm {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onInput(callback: (input: string) => void) {
|
onInput(callback: (input: string) => void) {
|
||||||
this.term.on("data", (data) => {
|
this.onDataHandler = this.term.onData((data) => {
|
||||||
callback(data);
|
callback(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onResize(callback: (colmuns: number, rows: number) => void) {
|
onResize(callback: (colmuns: number, rows: number) => void) {
|
||||||
this.term.on("resize", (data) => {
|
this.onResizeHandler = this.term.onResize(() => {
|
||||||
callback(data.cols, data.rows);
|
callback(this.term.cols, this.term.rows);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
deactivate(): void {
|
deactivate(): void {
|
||||||
this.term.off("data");
|
this.onDataHandler.dispose();
|
||||||
this.term.off("resize");
|
this.onResizeHandler.dispose();
|
||||||
this.term.blur();
|
this.term.blur();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,6 +99,6 @@ export class Xterm {
|
|||||||
|
|
||||||
close(): void {
|
close(): void {
|
||||||
window.removeEventListener("resize", this.resizeListener);
|
window.removeEventListener("resize", this.resizeListener);
|
||||||
this.term.destroy();
|
this.term.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user