mirror of
https://github.com/wavetermdev/backup.git
synced 2026-08-05 13:57:07 -07:00
fixing focus bugs
This commit is contained in:
@@ -2284,6 +2284,10 @@ class MainSideBar extends React.Component<{}, {}> {
|
|||||||
activeRemoteId = rptr.remoteid;
|
activeRemoteId = rptr.remoteid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let sw : ScreenWindow = null;
|
||||||
|
if (GlobalModel.debugSW.get()) {
|
||||||
|
sw = GlobalModel.getActiveSW();
|
||||||
|
}
|
||||||
let session : Session = null;
|
let session : Session = null;
|
||||||
let remotes = model.remotes ?? [];
|
let remotes = model.remotes ?? [];
|
||||||
let remote : RemoteType = null;
|
let remote : RemoteType = null;
|
||||||
@@ -2350,6 +2354,13 @@ class MainSideBar extends React.Component<{}, {}> {
|
|||||||
</a></li>
|
</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div className="spacer"></div>
|
<div className="spacer"></div>
|
||||||
|
<If condition={GlobalModel.debugSW.get() && sw != null}>
|
||||||
|
<div>
|
||||||
|
focus={sw.focusType.get()}<br/>
|
||||||
|
sline={sw.selectedLine.get()}<br/>
|
||||||
|
termfocus={sw.termLineNumFocus.get()}<br/>
|
||||||
|
</div>
|
||||||
|
</If>
|
||||||
<p className="menu-label">
|
<p className="menu-label">
|
||||||
<a onClick={() => this.clickRemotes()}>Remotes</a>
|
<a onClick={() => this.clickRemotes()}>Remotes</a>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
+75
-18
@@ -16,6 +16,12 @@ const RemotePtyCols = 80;
|
|||||||
const MinTermCols = 10;
|
const MinTermCols = 10;
|
||||||
const MaxTermCols = 1024;
|
const MaxTermCols = 1024;
|
||||||
|
|
||||||
|
type SWLinePtr = {
|
||||||
|
line : LineType,
|
||||||
|
win : Window,
|
||||||
|
sw : ScreenWindow,
|
||||||
|
};
|
||||||
|
|
||||||
function widthToCols(width : number) : number {
|
function widthToCols(width : number) : number {
|
||||||
let cols = Math.trunc((width - 32) / DefaultCellWidth) - 1;
|
let cols = Math.trunc((width - 32) / DefaultCellWidth) - 1;
|
||||||
cols = boundInt(cols, MinTermCols, MaxTermCols);
|
cols = boundInt(cols, MinTermCols, MaxTermCols);
|
||||||
@@ -224,13 +230,6 @@ class Screen {
|
|||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePtyData(ptyMsg : PtyDataUpdateType) {
|
|
||||||
for (let i=0; i<this.windows.length; i++) {
|
|
||||||
let sw = this.windows[i];
|
|
||||||
sw.updatePtyData(ptyMsg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getActiveSW() : ScreenWindow {
|
getActiveSW() : ScreenWindow {
|
||||||
return this.getSW(this.activeWindowId.get());
|
return this.getSW(this.activeWindowId.get());
|
||||||
}
|
}
|
||||||
@@ -447,10 +446,14 @@ class ScreenWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setTermFocus(lineNum : number, focus : boolean) : void {
|
setTermFocus(lineNum : number, focus : boolean) : void {
|
||||||
|
// console.log("SW setTermFocus", lineNum, focus);
|
||||||
mobx.action(() => this.termLineNumFocus.set(focus ? lineNum : 0))();
|
mobx.action(() => this.termLineNumFocus.set(focus ? lineNum : 0))();
|
||||||
if (focus && this.selectedLine.get() != lineNum) {
|
if (focus && this.selectedLine.get() != lineNum) {
|
||||||
GlobalCommandRunner.swSelectLine(String(lineNum), "cmd");
|
GlobalCommandRunner.swSelectLine(String(lineNum), "cmd");
|
||||||
}
|
}
|
||||||
|
else if (focus && this.focusType.get() == "input") {
|
||||||
|
GlobalCommandRunner.swSetFocus("cmd");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
connectElem(elem : Element, line : LineType, cmd : Cmd, width : number) {
|
connectElem(elem : Element, line : LineType, cmd : Cmd, width : number) {
|
||||||
@@ -740,6 +743,17 @@ class Session {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSWs(windowId : string) : ScreenWindow[] {
|
||||||
|
let rtn : ScreenWindow[] = [];
|
||||||
|
for (let screen of this.screens) {
|
||||||
|
let sw = screen.getSW(windowId);
|
||||||
|
if (sw != null) {
|
||||||
|
rtn.push(sw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDefaultHistoryQueryOpts() : HistoryQueryOpts {
|
function getDefaultHistoryQueryOpts() : HistoryQueryOpts {
|
||||||
@@ -863,10 +877,12 @@ class InputModel {
|
|||||||
mobx.action(() => {
|
mobx.action(() => {
|
||||||
this.physicalInputFocused.set(isFocused);
|
this.physicalInputFocused.set(isFocused);
|
||||||
})();
|
})();
|
||||||
let sw = GlobalModel.getActiveSW();
|
if (isFocused) {
|
||||||
if (sw != null) {
|
let sw = GlobalModel.getActiveSW();
|
||||||
if (sw.focusType.get() != "input") {
|
if (sw != null) {
|
||||||
GlobalCommandRunner.swSetFocus("input");
|
if (sw.focusType.get() != "input") {
|
||||||
|
GlobalCommandRunner.swSetFocus("input");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1419,7 +1435,8 @@ class Model {
|
|||||||
termUsedRowsCache : Record<string, number> = {};
|
termUsedRowsCache : Record<string, number> = {};
|
||||||
remotesModalOpen : OV<boolean> = mobx.observable.box(false);
|
remotesModalOpen : OV<boolean> = mobx.observable.box(false);
|
||||||
addRemoteModalOpen : OV<boolean> = mobx.observable.box(false);
|
addRemoteModalOpen : OV<boolean> = mobx.observable.box(false);
|
||||||
debugCmds : boolean = false;
|
debugCmds : number = 0;
|
||||||
|
debugSW : OV<boolean> = mobx.observable.box(false);
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.clientId = getApi().getId();
|
this.clientId = getApi().getId();
|
||||||
@@ -1611,11 +1628,7 @@ class Model {
|
|||||||
let ptyMsg : PtyDataUpdateType = genUpdate;
|
let ptyMsg : PtyDataUpdateType = genUpdate;
|
||||||
if (isBlank(ptyMsg.remoteid)) {
|
if (isBlank(ptyMsg.remoteid)) {
|
||||||
// regular update
|
// regular update
|
||||||
let activeScreen = this.getActiveScreen();
|
this.updatePtyData(ptyMsg);
|
||||||
if (!activeScreen || activeScreen.sessionId != ptyMsg.sessionid) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
activeScreen.updatePtyData(ptyMsg);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1829,8 +1842,11 @@ class Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
submitCommandPacket(cmdPk : FeCmdPacketType, interactive : boolean) {
|
submitCommandPacket(cmdPk : FeCmdPacketType, interactive : boolean) {
|
||||||
if (this.debugCmds) {
|
if (this.debugCmds > 0) {
|
||||||
console.log("[cmd]", cmdPacketString(cmdPk));
|
console.log("[cmd]", cmdPacketString(cmdPk));
|
||||||
|
if (this.debugCmds > 1) {
|
||||||
|
console.trace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let url = sprintf("http://localhost:8080/api/run-command");
|
let url = sprintf("http://localhost:8080/api/run-command");
|
||||||
fetch(url, {method: "post", body: JSON.stringify(cmdPk)}).then((resp) => handleJsonFetchResponse(url, resp)).then((data) => {
|
fetch(url, {method: "post", body: JSON.stringify(cmdPk)}).then((resp) => handleJsonFetchResponse(url, resp)).then((data) => {
|
||||||
@@ -1963,6 +1979,47 @@ class Model {
|
|||||||
return window.getCmd(line.cmdid);
|
return window.getCmd(line.cmdid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getActiveLinesByCmdId(sessionid : string, cmdid : string) : SWLinePtr[] {
|
||||||
|
let rtn : SWLinePtr[] = [];
|
||||||
|
let session = this.getSessionById(sessionid);
|
||||||
|
if (session == null) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
for (let win of this.windows.values()) {
|
||||||
|
if (win.sessionId != sessionid) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!win.loaded.get()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let cmd = win.getCmd(cmdid);
|
||||||
|
if (cmd == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let winLine : LineType = null;
|
||||||
|
for (let i=0; i<win.lines.length; i++) {
|
||||||
|
if (win.lines[i].cmdid == cmdid) {
|
||||||
|
winLine = win.lines[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (winLine != null) {
|
||||||
|
let sws = session.getSWs(win.windowId);
|
||||||
|
for (let sw of sws) {
|
||||||
|
rtn.push({line : winLine, win: win, sw: sw});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
|
updatePtyData(ptyMsg : PtyDataUpdateType) : void {
|
||||||
|
let activeLinePtrs = this.getActiveLinesByCmdId(ptyMsg.sessionid, ptyMsg.cmdid);
|
||||||
|
for (let lineptr of activeLinePtrs) {
|
||||||
|
lineptr.sw.updatePtyData(ptyMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
errorHandler(str : string, err : any, interactive : boolean) {
|
errorHandler(str : string, err : any, interactive : boolean) {
|
||||||
console.log("[error]", str, err);
|
console.log("[error]", str, err);
|
||||||
if (interactive) {
|
if (interactive) {
|
||||||
|
|||||||
Reference in New Issue
Block a user