mirror of
https://github.com/sorenisanerd/gotty.git
synced 2024-11-22 12:24:25 +00:00
Move responsibility to decode output encoding to terminal implementation
This commit is contained in:
parent
807bcc25a4
commit
b2c2db0764
2
js/dist/gotty-bundle.js
vendored
2
js/dist/gotty-bundle.js
vendored
File diff suppressed because one or more lines are too long
6
js/dist/xterm.d.ts
vendored
6
js/dist/xterm.d.ts
vendored
@ -1,11 +1,13 @@
|
|||||||
import * as bare from "xterm";
|
import * as bare from "xterm";
|
||||||
|
import { lib } from "libapps";
|
||||||
export declare class Xterm {
|
export declare class Xterm {
|
||||||
elem: HTMLElement;
|
elem: HTMLElement;
|
||||||
|
term: bare;
|
||||||
|
resizeListener: () => void;
|
||||||
|
decoder: lib.UTF8Decoder;
|
||||||
message: HTMLElement;
|
message: HTMLElement;
|
||||||
messageTimeout: number;
|
messageTimeout: number;
|
||||||
messageTimer: number;
|
messageTimer: number;
|
||||||
term: bare;
|
|
||||||
resizeListener: () => void;
|
|
||||||
constructor(elem: HTMLElement);
|
constructor(elem: HTMLElement);
|
||||||
info(): {
|
info(): {
|
||||||
columns: number;
|
columns: number;
|
||||||
|
@ -29,7 +29,7 @@ export class Hterm {
|
|||||||
|
|
||||||
output(data: string) {
|
output(data: string) {
|
||||||
if (this.term.io != null) {
|
if (this.term.io != null) {
|
||||||
this.term.io.writeUTF16(data);
|
this.term.io.writeUTF8(data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import { lib } from "libapps"
|
|
||||||
|
|
||||||
export const protocols = ["webtty"];
|
export const protocols = ["webtty"];
|
||||||
|
|
||||||
export const msgInputUnknown = '0';
|
export const msgInputUnknown = '0';
|
||||||
@ -65,8 +63,6 @@ export class WebTTY {
|
|||||||
let reconnectTimeout: number;
|
let reconnectTimeout: number;
|
||||||
|
|
||||||
const setup = () => {
|
const setup = () => {
|
||||||
const decoder = new lib.UTF8Decoder()
|
|
||||||
|
|
||||||
connection.onOpen(() => {
|
connection.onOpen(() => {
|
||||||
const termInfo = this.term.info();
|
const termInfo = this.term.info();
|
||||||
|
|
||||||
@ -108,7 +104,7 @@ export class WebTTY {
|
|||||||
const payload = data.slice(1);
|
const payload = data.slice(1);
|
||||||
switch (data[0]) {
|
switch (data[0]) {
|
||||||
case msgOutput:
|
case msgOutput:
|
||||||
this.term.output(decoder.decode(atob(payload)));
|
this.term.output(atob(payload));
|
||||||
break;
|
break;
|
||||||
case msgPong:
|
case msgPong:
|
||||||
break;
|
break;
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
import * as bare from "xterm";
|
import * as bare from "xterm";
|
||||||
|
import { lib } from "libapps"
|
||||||
|
|
||||||
|
|
||||||
bare.loadAddon("fit");
|
bare.loadAddon("fit");
|
||||||
|
|
||||||
export class Xterm {
|
export class Xterm {
|
||||||
elem: HTMLElement;
|
elem: HTMLElement;
|
||||||
|
term: bare;
|
||||||
|
resizeListener: () => void;
|
||||||
|
decoder: lib.UTF8Decoder;
|
||||||
|
|
||||||
message: HTMLElement;
|
message: HTMLElement;
|
||||||
messageTimeout: number;
|
messageTimeout: number;
|
||||||
messageTimer: number;
|
messageTimer: number;
|
||||||
|
|
||||||
term: bare;
|
|
||||||
resizeListener: () => void;
|
|
||||||
|
|
||||||
constructor(elem: HTMLElement) {
|
constructor(elem: HTMLElement) {
|
||||||
this.elem = elem;
|
this.elem = elem;
|
||||||
@ -20,7 +23,6 @@ export class Xterm {
|
|||||||
this.message.className = "xterm-overlay";
|
this.message.className = "xterm-overlay";
|
||||||
this.messageTimeout = 2000;
|
this.messageTimeout = 2000;
|
||||||
|
|
||||||
|
|
||||||
this.resizeListener = () => {
|
this.resizeListener = () => {
|
||||||
this.term.fit();
|
this.term.fit();
|
||||||
this.term.scrollToBottom();
|
this.term.scrollToBottom();
|
||||||
@ -33,6 +35,8 @@ export class Xterm {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.term.open(elem, true);
|
this.term.open(elem, true);
|
||||||
|
|
||||||
|
this.decoder = new lib.UTF8Decoder()
|
||||||
};
|
};
|
||||||
|
|
||||||
info(): { columns: number, rows: number } {
|
info(): { columns: number, rows: number } {
|
||||||
@ -40,7 +44,7 @@ export class Xterm {
|
|||||||
};
|
};
|
||||||
|
|
||||||
output(data: string) {
|
output(data: string) {
|
||||||
this.term.write(data);
|
this.term.write(this.decoder.decode(data));
|
||||||
};
|
};
|
||||||
|
|
||||||
showMessage(message: string, timeout: number) {
|
showMessage(message: string, timeout: number) {
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user