Skip to content

Commit

Permalink
Move responsibility to decode output encoding to terminal implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
yudai committed Aug 26, 2017
1 parent 807bcc2 commit b2c2db0
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion js/dist/gotty-bundle.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions js/dist/xterm.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import * as bare from "xterm";
import { lib } from "libapps";
export declare class Xterm {
elem: HTMLElement;
term: bare;
resizeListener: () => void;
decoder: lib.UTF8Decoder;
message: HTMLElement;
messageTimeout: number;
messageTimer: number;
term: bare;
resizeListener: () => void;
constructor(elem: HTMLElement);
info(): {
columns: number;
Expand Down
2 changes: 1 addition & 1 deletion js/src/hterm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class Hterm {

output(data: string) {
if (this.term.io != null) {
this.term.io.writeUTF16(data);
this.term.io.writeUTF8(data);
}
};

Expand Down
6 changes: 1 addition & 5 deletions js/src/webtty.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { lib } from "libapps"

export const protocols = ["webtty"];

export const msgInputUnknown = '0';
Expand Down Expand Up @@ -65,8 +63,6 @@ export class WebTTY {
let reconnectTimeout: number;

const setup = () => {
const decoder = new lib.UTF8Decoder()

connection.onOpen(() => {
const termInfo = this.term.info();

Expand Down Expand Up @@ -108,7 +104,7 @@ export class WebTTY {
const payload = data.slice(1);
switch (data[0]) {
case msgOutput:
this.term.output(decoder.decode(atob(payload)));
this.term.output(atob(payload));
break;
case msgPong:
break;
Expand Down
12 changes: 8 additions & 4 deletions js/src/xterm.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import * as bare from "xterm";
import { lib } from "libapps"


bare.loadAddon("fit");

export class Xterm {
elem: HTMLElement;
term: bare;
resizeListener: () => void;
decoder: lib.UTF8Decoder;

message: HTMLElement;
messageTimeout: number;
messageTimer: number;

term: bare;
resizeListener: () => void;

constructor(elem: HTMLElement) {
this.elem = elem;
Expand All @@ -20,7 +23,6 @@ export class Xterm {
this.message.className = "xterm-overlay";
this.messageTimeout = 2000;


this.resizeListener = () => {
this.term.fit();
this.term.scrollToBottom();
Expand All @@ -33,14 +35,16 @@ export class Xterm {
});

this.term.open(elem, true);

this.decoder = new lib.UTF8Decoder()
};

info(): { columns: number, rows: number } {
return { columns: this.term.cols, rows: this.term.rows };
};

output(data: string) {
this.term.write(data);
this.term.write(this.decoder.decode(data));
};

showMessage(message: string, timeout: number) {
Expand Down
4 changes: 2 additions & 2 deletions server/asset.go

Large diffs are not rendered by default.

0 comments on commit b2c2db0

Please sign in to comment.