mirror of
https://github.com/sorenisanerd/gotty.git
synced 2024-11-21 20:14:24 +00:00
Add WebGL and links addons for xterm.js
This commit is contained in:
parent
8d7358b3b3
commit
0dfc5aed76
2
Makefile
2
Makefile
@ -12,7 +12,7 @@ docker:
|
||||
.PHONY: asset
|
||||
asset: bindata/static/js/gotty.js bindata/static/index.html bindata/static/favicon.png bindata/static/css/index.css bindata/static/css/xterm.css bindata/static/css/xterm_customize.css bindata/static/manifest.json bindata/static/icon_192.png server/asset.go
|
||||
|
||||
server/asset.go:
|
||||
server/asset.go: bindata/* bindata/*/* bindata/*/*/*
|
||||
go-bindata -prefix bindata -pkg server -ignore=\\.gitkeep -o server/asset.go bindata/...
|
||||
gofmt -w server/asset.go
|
||||
|
||||
|
5
NEWS.md
5
NEWS.md
@ -1,5 +1,10 @@
|
||||
# GoTTY releases
|
||||
|
||||
## v1.3.0 (Unreleased)
|
||||
|
||||
* Links in the tty are now clickable.
|
||||
* Use WebGL for rendering by default.
|
||||
|
||||
## v1.2.0
|
||||
|
||||
* Pass BUILD\_OPTIONS to gox, too, so release artifacts have version info included.
|
||||
|
10
js/package-lock.json
generated
10
js/package-lock.json
generated
@ -1462,6 +1462,16 @@
|
||||
"resolved": "https://registry.npmjs.org/xterm-addon-fit/-/xterm-addon-fit-0.5.0.tgz",
|
||||
"integrity": "sha512-DsS9fqhXHacEmsPxBJZvfj2la30Iz9xk+UKjhQgnYNkrUIN5CYLbw7WEfz117c7+S86S/tpHPfvNxJsF5/G8wQ=="
|
||||
},
|
||||
"xterm-addon-web-links": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/xterm-addon-web-links/-/xterm-addon-web-links-0.4.0.tgz",
|
||||
"integrity": "sha512-xv8GeiINmx0zENO9hf5k+5bnkaE8mRzF+OBAr9WeFq2eLaQSudioQSiT34M1ofKbzcdjSsKiZm19Rw3i4eXamg=="
|
||||
},
|
||||
"xterm-addon-webgl": {
|
||||
"version": "0.10.0",
|
||||
"resolved": "https://registry.npmjs.org/xterm-addon-webgl/-/xterm-addon-webgl-0.10.0.tgz",
|
||||
"integrity": "sha512-MJzyWie5yw+PH6p//fXlXzmsULLtpBo992EWEKl2uv5M5Zj9etTwfuutCUK7o98mr6itDl+vS/CYIMP68jCf8w=="
|
||||
},
|
||||
"yocto-queue": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
|
||||
|
@ -14,6 +14,8 @@
|
||||
"libapps": "github:yudai/libapps#release-hterm-1.70",
|
||||
"style-loader": "^2.0.0",
|
||||
"xterm": "^4.11.0",
|
||||
"xterm-addon-fit": "^0.5.0"
|
||||
"xterm-addon-fit": "^0.5.0",
|
||||
"xterm-addon-web-links": "^0.4.0",
|
||||
"xterm-addon-webgl": "^0.10.0"
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,9 @@ export class Hterm {
|
||||
|
||||
setPreferences(value: object) {
|
||||
Object.keys(value).forEach((key) => {
|
||||
if (key != "EnableWebGL") {
|
||||
this.term.getPrefs().set(key, value[key]);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -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) {
|
||||
|
File diff suppressed because one or more lines are too long
@ -154,9 +154,12 @@ func (server *Server) processWSConn(ctx context.Context, conn *websocket.Conn) e
|
||||
if server.options.Height > 0 {
|
||||
opts = append(opts, webtty.WithFixedRows(server.options.Height))
|
||||
}
|
||||
if server.options.Preferences != nil {
|
||||
opts = append(opts, webtty.WithMasterPreferences(server.options.Preferences))
|
||||
if server.options.Preferences == nil {
|
||||
server.options.Preferences = &HtermPrefernces{}
|
||||
}
|
||||
// Awkward hack until HtermPreferences can be phased out
|
||||
server.options.Preferences.EnableWebGL = server.options.EnableWebGL
|
||||
opts = append(opts, webtty.WithMasterPreferences(server.options.Preferences))
|
||||
|
||||
tty, err := webtty.New(&wsWrapper{conn}, slave, opts...)
|
||||
if err != nil {
|
||||
|
@ -31,6 +31,7 @@ type Options struct {
|
||||
Height int `hcl:"height" flagName:"height" flagDescribe:"Static height of the screen, 0(default) means dynamically resize" default:"0"`
|
||||
WSOrigin string `hcl:"ws_origin" flagName:"ws-origin" flagDescribe:"A regular expression that matches origin URLs to be accepted by WebSocket. No cross origin requests are acceptable by default" default:""`
|
||||
Term string `hcl:"term" flagName:"term" flagDescribe:"Terminal name to use on the browser, one of xterm or hterm." default:"xterm"`
|
||||
EnableWebGL bool `hcl:"enable_webgl" flagName:"enable-webgl" flagDescribe:"Enable WebGL renderer" default:"true"`
|
||||
|
||||
TitleVariables map[string]interface{}
|
||||
}
|
||||
@ -73,6 +74,7 @@ type HtermPrefernces struct {
|
||||
EnableClipboardNotice bool `hcl:"enable_clipboard_notice" json:"enable-clipboard-notice,omitempty"`
|
||||
EnableClipboardWrite bool `hcl:"enable_clipboard_write" json:"enable-clipboard-write,omitempty"`
|
||||
EnableDec12 bool `hcl:"enable_dec12" json:"enable-dec12,omitempty"`
|
||||
EnableWebGL bool `json:"EnableWebGL,omitempty"`
|
||||
Environment map[string]string `hcl:"environment" json:"environment,omitempty"`
|
||||
FontFamily string `hcl:"font_family" json:"font-family,omitempty"`
|
||||
FontSize int `hcl:"font_size" json:"font-size,omitempty"`
|
||||
|
Loading…
Reference in New Issue
Block a user