Skip to content
This repository was archived by the owner on Oct 22, 2021. It is now read-only.

Commit d723b5f

Browse files
committed
🐛 Fix fsDisp not following tabs & tab titles
1 parent bc66a57 commit d723b5f

File tree

3 files changed

+52
-12
lines changed

3 files changed

+52
-12
lines changed

src/_renderer.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ initGreeter = () => {
295295
})
296296
};
297297
window.currentTerm = 0;
298+
window.term[0].onprocesschange = p => {
299+
document.getElementById("shell_tab0").innerText = "MAIN - "+p;
300+
};
298301
// Prevent losing hardware keyboard focus on the terminal when using touch keyboard
299302
window.onmouseup = (e) => {
300303
window.term[window.currentTerm].term.focus();
@@ -316,6 +319,14 @@ initGreeter = () => {
316319

317320
window.themeChanger = (theme) => {
318321
window.focusShellTab(0);
322+
for (let i = 1; i <= 4; i++) {
323+
if (typeof window.term[i] !== undefined) {
324+
window.term[i].socket.close();
325+
delete window.term[i];
326+
document.getElementById("shell_tab"+i).innerText = "EMPTY";
327+
document.getElementById("terminal"+i).innerHTML = "";
328+
}
329+
}
319330

320331
let src = path.join(themesDir, theme+".json" || settings.theme+".json");
321332
// Always get fresh theme files
@@ -348,6 +359,11 @@ window.themeChanger = (theme) => {
348359
})
349360
};
350361
window.currentTerm = 0;
362+
window.term[0].onprocesschange = p => {
363+
document.getElementById("shell_tab0").innerText = "MAIN - "+p;
364+
};
365+
366+
351367
initMods();
352368
window.fsDisp = new FilesystemDisplay({
353369
parentId: "filesystem"
@@ -383,6 +399,8 @@ window.focusShellTab = (number) => {
383399
window.term[number].fit();
384400
window.term[number].term.focus();
385401
window.term[number].resendCWD();
402+
403+
window.fsDisp.followTab();
386404
} else if (number > 0 && number <= 4 && window.term[number] !== null) {
387405
window.term[number] = null;
388406

@@ -401,12 +419,17 @@ window.focusShellTab = (number) => {
401419
});
402420

403421
window.term[number].onclose = e => {
422+
delete window.term[number].onprocesschange;
404423
document.getElementById("shell_tab"+number).innerText = "EMPTY";
405424
document.getElementById("terminal"+number).innerHTML = "";
406425
delete window.term[number];
407426
window.focusShellTab(0);
408427
};
409428

429+
window.term[number].onprocesschange = p => {
430+
document.getElementById("shell_tab"+number).innerText = `#${number} - ${p}`;
431+
};
432+
410433
document.getElementById("shell_tab"+number).innerText = "::"+port;
411434
setTimeout(() => {
412435
window.focusShellTab(number);

src/classes/filesystem.class.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,25 @@ class FilesystemDisplay {
5555
<h2 id="fs_disp_error">CANNOT ACCESS CURRENT WORKING DIRECTORY</h2>`;
5656
};
5757

58-
window.term[window.currentTerm].oncwdchange = (cwd) => {
59-
if (cwd) {
60-
if (this._fsWatcher) {
61-
this._fsWatcher.close();
62-
}
63-
if (cwd.startsWith("FALLBACK |-- ")) {
64-
this.readFS(cwd.slice(13));
65-
this._noTracking = true;
66-
} else {
67-
this.readFS(cwd);
68-
this.watchFS(cwd);
58+
this.followTab = () => {
59+
let num = window.currentTerm;
60+
61+
window.term[num].oncwdchange = (cwd) => {
62+
if (cwd && window.currentTerm === num) {
63+
if (this._fsWatcher) {
64+
this._fsWatcher.close();
65+
}
66+
if (cwd.startsWith("FALLBACK |-- ")) {
67+
this.readFS(cwd.slice(13));
68+
this._noTracking = true;
69+
} else {
70+
this.readFS(cwd);
71+
this.watchFS(cwd);
72+
}
6973
}
70-
}
74+
};
7175
};
76+
this.followTab();
7277

7378
this.watchFS = (dir) => {
7479
if (this._fsWatcher) {

src/classes/terminal.class.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ class Terminal {
8585
this.cwd = "FALLBACK |-- "+args[1];
8686
this.oncwdchange(this.cwd);
8787
break;
88+
case "New process":
89+
if (this.onprocesschange) {
90+
this.onprocesschange(args[1]);
91+
}
92+
break;
8893
default:
8994
return;
9095
}
@@ -239,6 +244,7 @@ class Terminal {
239244
});
240245
};
241246
this._nextTickUpdateTtyCWD = false;
247+
this._nextTickUpdateProcess = false;
242248
this._tick = setInterval(() => {
243249
if (this._nextTickUpdateTtyCWD && this._disableCWDtracking === false) {
244250
this._nextTickUpdateTtyCWD = false;
@@ -258,6 +264,11 @@ class Terminal {
258264
}
259265
});
260266
}
267+
268+
if (this.renderer && this._nextTickUpdateProcess) {
269+
this.renderer.send("terminal_channel-"+this.port, "New process", this.tty._file);
270+
this._nextTickUpdateProcess = false;
271+
}
261272
}, 1000);
262273

263274
this.tty = this.Pty.spawn(opts.shell || "bash", opts.params || [], {
@@ -315,6 +326,7 @@ class Terminal {
315326
});
316327
this.tty.on("data", (data) => {
317328
this._nextTickUpdateTtyCWD = true;
329+
this._nextTickUpdateProcess = true;
318330
try {
319331
ws.send(data);
320332
} catch (e) {

0 commit comments

Comments
 (0)