|
|
|
@ -1,6 +1,7 @@
@@ -1,6 +1,7 @@
|
|
|
|
|
import { bind } from 'decko'; |
|
|
|
|
import { Component, h } from 'preact'; |
|
|
|
|
import { ITerminalOptions, Terminal } from 'xterm'; |
|
|
|
|
import { Unicode11Addon } from 'xterm-addon-unicode11'; |
|
|
|
|
import { FitAddon } from 'xterm-addon-fit'; |
|
|
|
|
import { WebglAddon } from 'xterm-addon-webgl'; |
|
|
|
|
import { WebLinksAddon } from 'xterm-addon-web-links'; |
|
|
|
@ -85,6 +86,25 @@ export class Xterm extends Component<Props> {
@@ -85,6 +86,25 @@ export class Xterm extends Component<Props> {
|
|
|
|
|
|
|
|
|
|
window.addEventListener('resize', this.onWindowResize); |
|
|
|
|
window.addEventListener('beforeunload', this.onWindowUnload); |
|
|
|
|
console.log("adding listener?"); |
|
|
|
|
this.terminal.element.addEventListener('paste', () => { |
|
|
|
|
console.log("fired?"); |
|
|
|
|
/* |
|
|
|
|
var items = event.clipboardData.items; |
|
|
|
|
console.log(JSON.stringify(items)); // might give you mime types
|
|
|
|
|
for (var index in items) { |
|
|
|
|
var item = items[index]; |
|
|
|
|
if (item.kind === 'file') { |
|
|
|
|
var blob = item.getAsFile(); |
|
|
|
|
var reader = new FileReader(); |
|
|
|
|
reader.onload = function (event) { |
|
|
|
|
console.log(event.target.result); // data url!
|
|
|
|
|
}; |
|
|
|
|
reader.readAsDataURL(blob); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
*/ |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
componentWillUnmount() { |
|
|
|
@ -176,6 +196,9 @@ export class Xterm extends Component<Props> {
@@ -176,6 +196,9 @@ export class Xterm extends Component<Props> {
|
|
|
|
|
terminal.loadAddon(overlayAddon); |
|
|
|
|
terminal.loadAddon(new WebLinksAddon()); |
|
|
|
|
terminal.loadAddon(this.zmodemAddon); |
|
|
|
|
terminal.loadAddon(new Unicode11Addon()); |
|
|
|
|
|
|
|
|
|
terminal.unicode.activeVersion = '11'; |
|
|
|
|
|
|
|
|
|
terminal.onTitleChange(data => { |
|
|
|
|
if (data && data !== '' && !this.titleFixed) { |
|
|
|
@ -184,6 +207,19 @@ export class Xterm extends Component<Props> {
@@ -184,6 +207,19 @@ export class Xterm extends Component<Props> {
|
|
|
|
|
}); |
|
|
|
|
terminal.onData(this.onTerminalData); |
|
|
|
|
terminal.onResize(this.onTerminalResize); |
|
|
|
|
terminal.parser.registerDcsHandler({prefix: "?", final: "a"}, (data, _) => { |
|
|
|
|
let text = atob(data); |
|
|
|
|
console.log("[ttyd] got notification escape sequence: " + text); |
|
|
|
|
try { |
|
|
|
|
let parsed = JSON.parse(text); |
|
|
|
|
new Notification(parsed.title, parsed); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
catch (e) { |
|
|
|
|
console.error("[ttyd] parse failed: " + e); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
if (document.queryCommandSupported && document.queryCommandSupported('copy')) { |
|
|
|
|
terminal.onSelectionChange(() => { |
|
|
|
|
if (terminal.getSelection() === '') return; |
|
|
|
|