mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-21 21:32:13 +01:00
fixing focus bugs
This commit is contained in:
parent
a0de45949f
commit
5c8dabbb2c
11
src/main.tsx
11
src/main.tsx
@ -2284,6 +2284,10 @@ class MainSideBar extends React.Component<{}, {}> {
|
||||
activeRemoteId = rptr.remoteid;
|
||||
}
|
||||
}
|
||||
let sw : ScreenWindow = null;
|
||||
if (GlobalModel.debugSW.get()) {
|
||||
sw = GlobalModel.getActiveSW();
|
||||
}
|
||||
let session : Session = null;
|
||||
let remotes = model.remotes ?? [];
|
||||
let remote : RemoteType = null;
|
||||
@ -2350,6 +2354,13 @@ class MainSideBar extends React.Component<{}, {}> {
|
||||
</a></li>
|
||||
</ul>
|
||||
<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">
|
||||
<a onClick={() => this.clickRemotes()}>Remotes</a>
|
||||
</p>
|
||||
|
93
src/model.ts
93
src/model.ts
@ -16,6 +16,12 @@ const RemotePtyCols = 80;
|
||||
const MinTermCols = 10;
|
||||
const MaxTermCols = 1024;
|
||||
|
||||
type SWLinePtr = {
|
||||
line : LineType,
|
||||
win : Window,
|
||||
sw : ScreenWindow,
|
||||
};
|
||||
|
||||
function widthToCols(width : number) : number {
|
||||
let cols = Math.trunc((width - 32) / DefaultCellWidth) - 1;
|
||||
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 {
|
||||
return this.getSW(this.activeWindowId.get());
|
||||
}
|
||||
@ -447,10 +446,14 @@ class ScreenWindow {
|
||||
}
|
||||
|
||||
setTermFocus(lineNum : number, focus : boolean) : void {
|
||||
// console.log("SW setTermFocus", lineNum, focus);
|
||||
mobx.action(() => this.termLineNumFocus.set(focus ? lineNum : 0))();
|
||||
if (focus && this.selectedLine.get() != lineNum) {
|
||||
GlobalCommandRunner.swSelectLine(String(lineNum), "cmd");
|
||||
}
|
||||
else if (focus && this.focusType.get() == "input") {
|
||||
GlobalCommandRunner.swSetFocus("cmd");
|
||||
}
|
||||
}
|
||||
|
||||
connectElem(elem : Element, line : LineType, cmd : Cmd, width : number) {
|
||||
@ -740,6 +743,17 @@ class Session {
|
||||
}
|
||||
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 {
|
||||
@ -863,10 +877,12 @@ class InputModel {
|
||||
mobx.action(() => {
|
||||
this.physicalInputFocused.set(isFocused);
|
||||
})();
|
||||
let sw = GlobalModel.getActiveSW();
|
||||
if (sw != null) {
|
||||
if (sw.focusType.get() != "input") {
|
||||
GlobalCommandRunner.swSetFocus("input");
|
||||
if (isFocused) {
|
||||
let sw = GlobalModel.getActiveSW();
|
||||
if (sw != null) {
|
||||
if (sw.focusType.get() != "input") {
|
||||
GlobalCommandRunner.swSetFocus("input");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1419,7 +1435,8 @@ class Model {
|
||||
termUsedRowsCache : Record<string, number> = {};
|
||||
remotesModalOpen : 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() {
|
||||
this.clientId = getApi().getId();
|
||||
@ -1611,11 +1628,7 @@ class Model {
|
||||
let ptyMsg : PtyDataUpdateType = genUpdate;
|
||||
if (isBlank(ptyMsg.remoteid)) {
|
||||
// regular update
|
||||
let activeScreen = this.getActiveScreen();
|
||||
if (!activeScreen || activeScreen.sessionId != ptyMsg.sessionid) {
|
||||
return;
|
||||
}
|
||||
activeScreen.updatePtyData(ptyMsg);
|
||||
this.updatePtyData(ptyMsg);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
@ -1829,8 +1842,11 @@ class Model {
|
||||
}
|
||||
|
||||
submitCommandPacket(cmdPk : FeCmdPacketType, interactive : boolean) {
|
||||
if (this.debugCmds) {
|
||||
if (this.debugCmds > 0) {
|
||||
console.log("[cmd]", cmdPacketString(cmdPk));
|
||||
if (this.debugCmds > 1) {
|
||||
console.trace();
|
||||
}
|
||||
}
|
||||
let url = sprintf("http://localhost:8080/api/run-command");
|
||||
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);
|
||||
}
|
||||
|
||||
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) {
|
||||
console.log("[error]", str, err);
|
||||
if (interactive) {
|
||||
|
Loading…
Reference in New Issue
Block a user