mirror of
https://github.com/wavetermdev/backup.git
synced 2026-08-05 13:57:07 -07:00
setTUR will now set the usedrows into the backend. linetype sends used rows so the screen updates better on first load (perf as well)
This commit is contained in:
+3
-1
@@ -441,7 +441,7 @@ class LineCmd extends React.Component<{sw : ScreenWindow, line : LineType, width
|
||||
);
|
||||
}
|
||||
let termLoaded = this.termLoaded.get();
|
||||
let usedRows = sw.getUsedRows(cmd, width);
|
||||
let usedRows = sw.getUsedRows(line, cmd, width);
|
||||
let termHeight = termHeightFromRows(usedRows);
|
||||
let remote = model.getRemote(cmd.remoteId);
|
||||
let status = cmd.getStatus();
|
||||
@@ -1952,6 +1952,7 @@ class LinesView extends React.Component<{sw : ScreenWindow, width : number, line
|
||||
let containerTop = linesElem.scrollTop - LinesVisiblePadding;
|
||||
let containerBot = linesElem.scrollTop + linesElem.clientHeight + LinesVisiblePadding;
|
||||
let newMap = new Map<string, boolean>();
|
||||
// console.log("computevismap", linesElem.scrollTop, linesElem.clientHeight, containerTop + "-" + containerBot);
|
||||
for (let i=0; i<lineElemArr.length; i++) {
|
||||
let lineElem = lineElemArr[i];
|
||||
let lineTop = lineElem.offsetTop;
|
||||
@@ -1964,6 +1965,7 @@ class LinesView extends React.Component<{sw : ScreenWindow, width : number, line
|
||||
isVis = true
|
||||
}
|
||||
newMap.set(lineElem.dataset.linenum, isVis);
|
||||
// console.log("setvis", sprintf("%4d %4d-%4d (%4d) %s", lineElem.dataset.linenum, lineTop, lineBot, lineElem.offsetHeight, isVis));
|
||||
}
|
||||
mobx.action(() => {
|
||||
for (let [k, v] of newMap) {
|
||||
|
||||
+18
-9
@@ -5,7 +5,7 @@ import {debounce} from "throttle-debounce";
|
||||
import {handleJsonFetchResponse, base64ToArray, genMergeData, genMergeSimpleData, boundInt, isModKeyPress} from "./util";
|
||||
import {TermWrap} from "./term";
|
||||
import {v4 as uuidv4} from "uuid";
|
||||
import type {SessionDataType, WindowDataType, LineType, RemoteType, HistoryItem, RemoteInstanceType, RemotePtrType, CmdDataType, FeCmdPacketType, TermOptsType, RemoteStateType, ScreenDataType, ScreenWindowType, ScreenOptsType, LayoutType, PtyDataUpdateType, ModelUpdateType, UpdateMessage, InfoType, CmdLineUpdateType, UIContextType, HistoryInfoType, HistoryQueryOpts, FeInputPacketType, TermWinSize, RemoteInputPacketType, FeStateType, ContextMenuOpts} from "./types";
|
||||
import type {SessionDataType, WindowDataType, LineType, RemoteType, HistoryItem, RemoteInstanceType, RemotePtrType, CmdDataType, FeCmdPacketType, TermOptsType, RemoteStateType, ScreenDataType, ScreenWindowType, ScreenOptsType, LayoutType, PtyDataUpdateType, ModelUpdateType, UpdateMessage, InfoType, CmdLineUpdateType, UIContextType, HistoryInfoType, HistoryQueryOpts, FeInputPacketType, TermWinSize, RemoteInputPacketType, FeStateType, ContextMenuOpts, NormalTermContext} from "./types";
|
||||
import {WSControl} from "./ws";
|
||||
|
||||
var GlobalUser = "sawka";
|
||||
@@ -554,6 +554,9 @@ class ScreenWindow {
|
||||
}
|
||||
let cols = widthToCols(width);
|
||||
let usedRows = GlobalModel.getTUR(this.sessionId, cmdId, cols);
|
||||
if (line.contentheight != null && line.contentheight != -1) {
|
||||
usedRows = line.contentheight;
|
||||
}
|
||||
let termContext = {sessionId: this.sessionId, screenId: this.screenId, windowId: this.windowId, cmdId: cmdId, lineNum: line.linenum};
|
||||
termWrap = new TermWrap(elem, {
|
||||
termContext: termContext,
|
||||
@@ -580,7 +583,7 @@ class ScreenWindow {
|
||||
}
|
||||
}
|
||||
|
||||
getUsedRows(cmd : Cmd, width : number) : number {
|
||||
getUsedRows(line : LineType, cmd : Cmd, width : number) : number {
|
||||
let termOpts = cmd.getTermOpts();
|
||||
if (!termOpts.flexrows) {
|
||||
return termOpts.rows;
|
||||
@@ -592,6 +595,9 @@ class ScreenWindow {
|
||||
if (usedRows != null) {
|
||||
return usedRows;
|
||||
}
|
||||
if (line.contentheight != null && line.contentheight != -1) {
|
||||
return line.contentheight;
|
||||
}
|
||||
return (cmd.isRunning() ? 1 : 0);
|
||||
}
|
||||
return termWrap.usedRows.get();
|
||||
@@ -1662,9 +1668,10 @@ class Model {
|
||||
return this.termUsedRowsCache[key];
|
||||
}
|
||||
|
||||
setTUR(sessionId : string, cmdId : string, size : TermWinSize, usedRows : number) : void {
|
||||
let key = sessionId + "/" + cmdId + "/" + size.cols;
|
||||
setTUR(termContext : NormalTermContext, size : TermWinSize, usedRows : number) : void {
|
||||
let key = termContext.sessionId + "/" + termContext.cmdId + "/" + size.cols;
|
||||
this.termUsedRowsCache[key] = usedRows;
|
||||
GlobalCommandRunner.setTermUsedRows(termContext, usedRows);
|
||||
}
|
||||
|
||||
contextScreen(e : any, screenId : string) {
|
||||
@@ -1753,7 +1760,7 @@ class Model {
|
||||
let term = sw.getTermWrap(cmdId);
|
||||
if (term != null) {
|
||||
term.setIsRunning(cmdStatusIsRunning(newStatus));
|
||||
term.updateUsedRows(true);
|
||||
term.updateUsedRows(true, "cmd-status");
|
||||
// setTimeout(() => term.updateUsedRows(true), 500);
|
||||
}
|
||||
}
|
||||
@@ -2354,12 +2361,14 @@ class CommandRunner {
|
||||
GlobalModel.submitCommand("sw", "set", null, kwargs, true);
|
||||
}
|
||||
|
||||
setLineHeight(lineArg : string, height : number) {
|
||||
setTermUsedRows(termContext : NormalTermContext, height : number) {
|
||||
let kwargs : Record<string, string> = {};
|
||||
kwargs["line"] = lineArg;
|
||||
kwargs["height"] = String(height);
|
||||
kwargs["session"] = termContext.sessionId;
|
||||
kwargs["screen"] = termContext.screenId;
|
||||
kwargs["window"] = termContext.windowId;
|
||||
kwargs["hohist"] = "1";
|
||||
GlobalModel.submitCommand("line", "setheight", null, kwargs, false);
|
||||
let posargs = [String(termContext.lineNum), String(height)];
|
||||
GlobalModel.submitCommand("line", "setheight", posargs, kwargs, false);
|
||||
}
|
||||
|
||||
swSetAnchor(sessionId : string, screenId : string, windowId : string, anchorVal : string) : void {
|
||||
|
||||
+11
-19
@@ -5,7 +5,7 @@ import {boundMethod} from "autobind-decorator";
|
||||
import {v4 as uuidv4} from "uuid";
|
||||
import {GlobalModel, widthToCols, GlobalCommandRunner} from "./model";
|
||||
import {boundInt} from "./util";
|
||||
import type {TermOptsType, TermWinSize} from "./types";
|
||||
import type {TermOptsType, TermWinSize, NormalTermContext} from "./types";
|
||||
|
||||
type DataUpdate = {
|
||||
data : Uint8Array,
|
||||
@@ -20,7 +20,6 @@ type WindowSize = {
|
||||
const MinTermCols = 10;
|
||||
const MaxTermCols = 1024;
|
||||
|
||||
type NormalTermContext = {sessionId : string, screenId : string, windowId : string, cmdId : string, lineNum : number};
|
||||
type RemoteTermContext = {remoteId : string};
|
||||
|
||||
type TermContext = NormalTermContext | RemoteTermContext;
|
||||
@@ -185,7 +184,7 @@ class TermWrap {
|
||||
return usedRows;
|
||||
}
|
||||
|
||||
updateUsedRows(forceFull : boolean) {
|
||||
updateUsedRows(forceFull : boolean, reason : string) {
|
||||
if (this.terminal == null) {
|
||||
return;
|
||||
}
|
||||
@@ -211,20 +210,11 @@ class TermWrap {
|
||||
if (!forceFull && tur <= oldUsedRows) {
|
||||
return;
|
||||
}
|
||||
this.usedRows.set(tur);
|
||||
GlobalModel.setTUR(termContext.sessionId, termContext.cmdId, this.termSize, tur);
|
||||
if (this.connectedElem) {
|
||||
let resizeEvent = new CustomEvent("termresize", {
|
||||
bubbles: true,
|
||||
detail: {
|
||||
cmdId: termContext.cmdId,
|
||||
oldUsedRows: oldUsedRows,
|
||||
newUsedRows: tur,
|
||||
},
|
||||
});
|
||||
// console.log("resize-event", resizeEvent);
|
||||
this.connectedElem.dispatchEvent(resizeEvent);
|
||||
if (tur == oldUsedRows) {
|
||||
return;
|
||||
}
|
||||
this.usedRows.set(tur);
|
||||
GlobalModel.setTUR(termContext, this.termSize, tur);
|
||||
})();
|
||||
}
|
||||
|
||||
@@ -243,7 +233,7 @@ class TermWrap {
|
||||
}
|
||||
this.termSize = newSize;
|
||||
this.terminal.resize(newSize.cols, newSize.rows);
|
||||
this.updateUsedRows(true);
|
||||
this.updateUsedRows(true, "resize");
|
||||
}
|
||||
|
||||
_getReloadUrl() : string {
|
||||
@@ -283,7 +273,9 @@ class TermWrap {
|
||||
this.updatePtyData(this.dataUpdates[i].pos, this.dataUpdates[i].data, "reload-update-" + i);
|
||||
}
|
||||
this.dataUpdates = [];
|
||||
this.updateUsedRows(true);
|
||||
this.terminal.write(new Uint8Array(), () => {
|
||||
this.updateUsedRows(true, "reload");
|
||||
});
|
||||
}, delayMs);
|
||||
}).catch((e) => {
|
||||
console.log("error reloading terminal", e);
|
||||
@@ -317,7 +309,7 @@ class TermWrap {
|
||||
}
|
||||
this.ptyPos += data.length;
|
||||
this.terminal.write(data, () => {
|
||||
this.updateUsedRows(false);
|
||||
this.updateUsedRows(false, "updatePtyData");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+9
-1
@@ -333,4 +333,12 @@ type ContextMenuOpts = {
|
||||
|
||||
type UpdateMessage = PtyDataUpdateType | ModelUpdateType;
|
||||
|
||||
export type {SessionDataType, LineType, RemoteType, RemoteStateType, RemoteInstanceType, WindowDataType, HistoryItem, CmdRemoteStateType, FeCmdPacketType, TermOptsType, CmdStartPacketType, CmdDataType, ScreenDataType, ScreenOptsType, ScreenWindowType, LayoutType, PtyDataUpdateType, ModelUpdateType, UpdateMessage, InfoType, CmdLineUpdateType, RemotePtrType, UIContextType, HistoryInfoType, HistoryQueryOpts, WatchScreenPacketType, TermWinSize, FeInputPacketType, RemoteInputPacketType, RemoteEditType, FeStateType, ContextMenuOpts};
|
||||
type NormalTermContext = {
|
||||
sessionId : string,
|
||||
screenId : string,
|
||||
windowId : string,
|
||||
cmdId : string,
|
||||
lineNum : number,
|
||||
};
|
||||
|
||||
export type {SessionDataType, LineType, RemoteType, RemoteStateType, RemoteInstanceType, WindowDataType, HistoryItem, CmdRemoteStateType, FeCmdPacketType, TermOptsType, CmdStartPacketType, CmdDataType, ScreenDataType, ScreenOptsType, ScreenWindowType, LayoutType, PtyDataUpdateType, ModelUpdateType, UpdateMessage, InfoType, CmdLineUpdateType, RemotePtrType, UIContextType, HistoryInfoType, HistoryQueryOpts, WatchScreenPacketType, TermWinSize, FeInputPacketType, RemoteInputPacketType, RemoteEditType, FeStateType, ContextMenuOpts, NormalTermContext};
|
||||
|
||||
Reference in New Issue
Block a user