mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-02-15 01:32:17 +01:00
read ptyoffset from header and initialize appropriately
This commit is contained in:
parent
225f120fbe
commit
fb899cd458
23
src/term.ts
23
src/term.ts
@ -6,19 +6,6 @@ import {v4 as uuidv4} from "uuid";
|
|||||||
import {GlobalModel} from "./model";
|
import {GlobalModel} from "./model";
|
||||||
import type {TermOptsType} from "./types";
|
import type {TermOptsType} from "./types";
|
||||||
|
|
||||||
function loadPtyOut(term : Terminal, sessionId : string, cmdId : string, delayMs : number, callback?: (number) => void) {
|
|
||||||
term.clear()
|
|
||||||
let url = sprintf("http://localhost:8080/api/ptyout?sessionid=%s&cmdid=%s", sessionId, cmdId);
|
|
||||||
fetch(url).then((resp) => {
|
|
||||||
if (!resp.ok) {
|
|
||||||
throw new Error(sprintf("Bad fetch response for /api/ptyout: %d %s", resp.status, resp.statusText));
|
|
||||||
}
|
|
||||||
return resp.text()
|
|
||||||
}).then((resptext) => {
|
|
||||||
setTimeout(() => term.write(resptext, () => { callback(resptext.length) }), delayMs);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
type DataUpdate = {
|
type DataUpdate = {
|
||||||
data : Uint8Array,
|
data : Uint8Array,
|
||||||
pos : number,
|
pos : number,
|
||||||
@ -180,18 +167,24 @@ class TermWrap {
|
|||||||
this.reloading = true;
|
this.reloading = true;
|
||||||
this.terminal.reset();
|
this.terminal.reset();
|
||||||
let url = sprintf("http://localhost:8080/api/ptyout?sessionid=%s&cmdid=%s", this.sessionId, this.cmdId);
|
let url = sprintf("http://localhost:8080/api/ptyout?sessionid=%s&cmdid=%s", this.sessionId, this.cmdId);
|
||||||
|
let ptyOffset = 0;
|
||||||
fetch(url).then((resp) => {
|
fetch(url).then((resp) => {
|
||||||
if (!resp.ok) {
|
if (!resp.ok) {
|
||||||
mobx.action(() => { this.loadError.set(true); })();
|
mobx.action(() => { this.loadError.set(true); })();
|
||||||
this.dataUpdates = [];
|
this.dataUpdates = [];
|
||||||
throw new Error(sprintf("Bad fetch response for /api/ptyout: %d %s", resp.status, resp.statusText));
|
throw new Error(sprintf("Bad fetch response for /api/ptyout: %d %s", resp.status, resp.statusText));
|
||||||
}
|
}
|
||||||
|
let ptyOffsetStr = resp.headers.get("X-PtyDataOffset");
|
||||||
|
if (ptyOffsetStr != null && !isNaN(parseInt(ptyOffsetStr))) {
|
||||||
|
ptyOffset = parseInt(ptyOffsetStr);
|
||||||
|
}
|
||||||
|
console.log("set ptyoffset", ptyOffset);
|
||||||
return resp.arrayBuffer()
|
return resp.arrayBuffer()
|
||||||
}).then((buf) => {
|
}).then((buf) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.reloading = false;
|
this.reloading = false;
|
||||||
this.ptyPos = 0;
|
this.ptyPos = ptyOffset;
|
||||||
this.updatePtyData(0, new Uint8Array(buf));
|
this.updatePtyData(ptyOffset, new Uint8Array(buf));
|
||||||
for (let i=0; i<this.dataUpdates.length; i++) {
|
for (let i=0; i<this.dataUpdates.length; i++) {
|
||||||
this.updatePtyData(this.dataUpdates[i].pos, this.dataUpdates[i].data);
|
this.updatePtyData(this.dataUpdates[i].pos, this.dataUpdates[i].data);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user