未验证 提交 d723b5fa 编写于 作者: G GitSquared

🐛 Fix fsDisp not following tabs & tab titles

上级 bc66a57d
...@@ -295,6 +295,9 @@ initGreeter = () => { ...@@ -295,6 +295,9 @@ initGreeter = () => {
}) })
}; };
window.currentTerm = 0; window.currentTerm = 0;
window.term[0].onprocesschange = p => {
document.getElementById("shell_tab0").innerText = "MAIN - "+p;
};
// Prevent losing hardware keyboard focus on the terminal when using touch keyboard // Prevent losing hardware keyboard focus on the terminal when using touch keyboard
window.onmouseup = (e) => { window.onmouseup = (e) => {
window.term[window.currentTerm].term.focus(); window.term[window.currentTerm].term.focus();
...@@ -316,6 +319,14 @@ initGreeter = () => { ...@@ -316,6 +319,14 @@ initGreeter = () => {
window.themeChanger = (theme) => { window.themeChanger = (theme) => {
window.focusShellTab(0); window.focusShellTab(0);
for (let i = 1; i <= 4; i++) {
if (typeof window.term[i] !== undefined) {
window.term[i].socket.close();
delete window.term[i];
document.getElementById("shell_tab"+i).innerText = "EMPTY";
document.getElementById("terminal"+i).innerHTML = "";
}
}
let src = path.join(themesDir, theme+".json" || settings.theme+".json"); let src = path.join(themesDir, theme+".json" || settings.theme+".json");
// Always get fresh theme files // Always get fresh theme files
...@@ -348,6 +359,11 @@ window.themeChanger = (theme) => { ...@@ -348,6 +359,11 @@ window.themeChanger = (theme) => {
}) })
}; };
window.currentTerm = 0; window.currentTerm = 0;
window.term[0].onprocesschange = p => {
document.getElementById("shell_tab0").innerText = "MAIN - "+p;
};
initMods(); initMods();
window.fsDisp = new FilesystemDisplay({ window.fsDisp = new FilesystemDisplay({
parentId: "filesystem" parentId: "filesystem"
...@@ -383,6 +399,8 @@ window.focusShellTab = (number) => { ...@@ -383,6 +399,8 @@ window.focusShellTab = (number) => {
window.term[number].fit(); window.term[number].fit();
window.term[number].term.focus(); window.term[number].term.focus();
window.term[number].resendCWD(); window.term[number].resendCWD();
window.fsDisp.followTab();
} else if (number > 0 && number <= 4 && window.term[number] !== null) { } else if (number > 0 && number <= 4 && window.term[number] !== null) {
window.term[number] = null; window.term[number] = null;
...@@ -401,12 +419,17 @@ window.focusShellTab = (number) => { ...@@ -401,12 +419,17 @@ window.focusShellTab = (number) => {
}); });
window.term[number].onclose = e => { window.term[number].onclose = e => {
delete window.term[number].onprocesschange;
document.getElementById("shell_tab"+number).innerText = "EMPTY"; document.getElementById("shell_tab"+number).innerText = "EMPTY";
document.getElementById("terminal"+number).innerHTML = ""; document.getElementById("terminal"+number).innerHTML = "";
delete window.term[number]; delete window.term[number];
window.focusShellTab(0); window.focusShellTab(0);
}; };
window.term[number].onprocesschange = p => {
document.getElementById("shell_tab"+number).innerText = `#${number} - ${p}`;
};
document.getElementById("shell_tab"+number).innerText = "::"+port; document.getElementById("shell_tab"+number).innerText = "::"+port;
setTimeout(() => { setTimeout(() => {
window.focusShellTab(number); window.focusShellTab(number);
......
...@@ -55,20 +55,25 @@ class FilesystemDisplay { ...@@ -55,20 +55,25 @@ class FilesystemDisplay {
<h2 id="fs_disp_error">CANNOT ACCESS CURRENT WORKING DIRECTORY</h2>`; <h2 id="fs_disp_error">CANNOT ACCESS CURRENT WORKING DIRECTORY</h2>`;
}; };
window.term[window.currentTerm].oncwdchange = (cwd) => { this.followTab = () => {
if (cwd) { let num = window.currentTerm;
if (this._fsWatcher) {
this._fsWatcher.close(); window.term[num].oncwdchange = (cwd) => {
} if (cwd && window.currentTerm === num) {
if (cwd.startsWith("FALLBACK |-- ")) { if (this._fsWatcher) {
this.readFS(cwd.slice(13)); this._fsWatcher.close();
this._noTracking = true; }
} else { if (cwd.startsWith("FALLBACK |-- ")) {
this.readFS(cwd); this.readFS(cwd.slice(13));
this.watchFS(cwd); this._noTracking = true;
} else {
this.readFS(cwd);
this.watchFS(cwd);
}
} }
} };
}; };
this.followTab();
this.watchFS = (dir) => { this.watchFS = (dir) => {
if (this._fsWatcher) { if (this._fsWatcher) {
......
...@@ -85,6 +85,11 @@ class Terminal { ...@@ -85,6 +85,11 @@ class Terminal {
this.cwd = "FALLBACK |-- "+args[1]; this.cwd = "FALLBACK |-- "+args[1];
this.oncwdchange(this.cwd); this.oncwdchange(this.cwd);
break; break;
case "New process":
if (this.onprocesschange) {
this.onprocesschange(args[1]);
}
break;
default: default:
return; return;
} }
...@@ -239,6 +244,7 @@ class Terminal { ...@@ -239,6 +244,7 @@ class Terminal {
}); });
}; };
this._nextTickUpdateTtyCWD = false; this._nextTickUpdateTtyCWD = false;
this._nextTickUpdateProcess = false;
this._tick = setInterval(() => { this._tick = setInterval(() => {
if (this._nextTickUpdateTtyCWD && this._disableCWDtracking === false) { if (this._nextTickUpdateTtyCWD && this._disableCWDtracking === false) {
this._nextTickUpdateTtyCWD = false; this._nextTickUpdateTtyCWD = false;
...@@ -258,6 +264,11 @@ class Terminal { ...@@ -258,6 +264,11 @@ class Terminal {
} }
}); });
} }
if (this.renderer && this._nextTickUpdateProcess) {
this.renderer.send("terminal_channel-"+this.port, "New process", this.tty._file);
this._nextTickUpdateProcess = false;
}
}, 1000); }, 1000);
this.tty = this.Pty.spawn(opts.shell || "bash", opts.params || [], { this.tty = this.Pty.spawn(opts.shell || "bash", opts.params || [], {
...@@ -315,6 +326,7 @@ class Terminal { ...@@ -315,6 +326,7 @@ class Terminal {
}); });
this.tty.on("data", (data) => { this.tty.on("data", (data) => {
this._nextTickUpdateTtyCWD = true; this._nextTickUpdateTtyCWD = true;
this._nextTickUpdateProcess = true;
try { try {
ws.send(data); ws.send(data);
} catch (e) { } catch (e) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册