Skip to content

Commit 8b3d6e4

Browse files
authored
feat: add uninstall option in terminal setting and tab subtitle fixes (Acode-Foundation#1445)
1 parent ea71abf commit 8b3d6e4

6 files changed

Lines changed: 77 additions & 123 deletions

File tree

package-lock.json

Lines changed: 2 additions & 120 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,4 @@
129129
"yargs": "^17.7.2"
130130
},
131131
"browserslist": "cover 100%,not android < 5"
132-
}
132+
}

src/components/terminal/terminalManager.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ class TerminalManager {
223223
terminalId,
224224
);
225225

226+
// Set up custom title for installation terminal
227+
terminalFile.setCustomTitle(
228+
() => "Installing Terminal Environment...",
229+
);
230+
226231
const instance = {
227232
id: terminalId,
228233
name: terminalName,
@@ -343,6 +348,15 @@ class TerminalManager {
343348
// Format terminal title as "Terminal ! - title"
344349
const formattedTitle = `Terminal ${this.terminalCounter} - ${title}`;
345350
terminalFile.filename = formattedTitle;
351+
352+
// Refresh the header subtitle if this terminal is active
353+
if (
354+
editorManager.activeFile &&
355+
editorManager.activeFile.id === terminalFile.id
356+
) {
357+
// Force refresh of the header subtitle
358+
terminalFile.setCustomTitle(getTerminalTitle);
359+
}
346360
}
347361
};
348362

@@ -366,6 +380,17 @@ class TerminalManager {
366380
terminalFile._terminalId = terminalId;
367381
terminalFile.terminalComponent = terminalComponent;
368382
terminalFile._resizeObserver = resizeObserver;
383+
384+
// Set up custom title function for terminal
385+
const getTerminalTitle = () => {
386+
if (terminalComponent.pid) {
387+
return `PID: ${terminalComponent.pid}`;
388+
}
389+
// fallback to terminal name
390+
return `${terminalId}`;
391+
};
392+
393+
terminalFile.setCustomTitle(getTerminalTitle);
369394
}
370395

371396
/**

src/lib/editorFile.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ export default class EditorFile {
6262
*/
6363
stylesheets;
6464

65+
/**
66+
* Custom title function for special tab types
67+
* @type {function}
68+
*/
69+
#customTitleFn = null;
70+
6571
/**
6672
* If editor was focused before resize
6773
*/
@@ -948,6 +954,18 @@ export default class EditorFile {
948954
this.#addCustomStyles(style, shadow);
949955
}
950956

957+
/**
958+
* Set custom title function for special tab types
959+
* @param {function} titleFn Function that returns the title string
960+
*/
961+
setCustomTitle(titleFn) {
962+
this.#customTitleFn = titleFn;
963+
// Update header if this file is currently active
964+
if (editorManager.activeFile && editorManager.activeFile.id === this.id) {
965+
editorManager.header.subText = this.#getTitle();
966+
}
967+
}
968+
951969
/**
952970
*
953971
* @param {FileAction} action
@@ -1196,6 +1214,11 @@ export default class EditorFile {
11961214
}
11971215

11981216
#getTitle() {
1217+
// Use custom title function if provided
1218+
if (this.#customTitleFn) {
1219+
return this.#customTitleFn();
1220+
}
1221+
11991222
let text = this.location || this.uri;
12001223

12011224
if (text && !this.readOnly) {

src/plugins/terminal/www/Terminal.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,9 @@ const Terminal = {
192192
return installResult;
193193

194194
} catch (e) {
195-
err_logger("Installation failed:", e);
196-
return false;
195+
err_logger("Installation failed:", e);
196+
console.error("Installation failed:", e);
197+
return false;
197198
}
198199
},
199200

src/settings/terminalSettings.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import loader from "dialogs/loader";
1010
import fonts from "lib/fonts";
1111
import appSettings from "lib/settings";
1212
import FileBrowser from "pages/fileBrowser";
13+
import helpers from "utils/helpers";
1314

1415
export default function terminalSettings() {
1516
const title = strings["terminal settings"];
@@ -173,6 +174,11 @@ export default function terminalSettings() {
173174
text: strings.restore.capitalize(),
174175
info: "Restores a backup of the terminal installation",
175176
},
177+
{
178+
key: "uninstall",
179+
text: strings.uninstall.capitalize(),
180+
info: "Uninstalls the terminal installation",
181+
},
176182
];
177183

178184
return settingsPage(title, items, callback);
@@ -206,6 +212,23 @@ export default function terminalSettings() {
206212
terminalRestore();
207213
return;
208214

215+
case "uninstall":
216+
loader.showTitleLoader();
217+
Terminal.uninstall()
218+
.then(() => {
219+
loader.removeTitleLoader();
220+
alert(
221+
strings.success.toUpperCase(),
222+
"Terminal uninstalled successfully.",
223+
);
224+
})
225+
.catch((error) => {
226+
loader.removeTitleLoader();
227+
console.error("Terminal uninstall failed:", error);
228+
helpers.error(error);
229+
});
230+
return;
231+
209232
default:
210233
appSettings.update({
211234
terminalSettings: {

0 commit comments

Comments
 (0)