From 4edac451e47c4aa5a0fe8c5fb2b0e23beef2b6a6 Mon Sep 17 00:00:00 2001 From: Quinten Kock Date: Tue, 18 Nov 2025 01:55:44 +0100 Subject: [PATCH] [terminal] Implement title changing and close-after-exit --- src/app/terminal.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/app/terminal.ts b/src/app/terminal.ts index 6ce15ac..ec2822b 100644 --- a/src/app/terminal.ts +++ b/src/app/terminal.ts @@ -1,12 +1,12 @@ import { Displayable } from "./editorgrid"; import * as xterm from "@xterm/xterm"; import { FitAddon } from "@xterm/addon-fit"; -import van from "vanjs-core"; +import van, { State } from "vanjs-core"; const v = van.tags; export class Terminal implements Displayable { term: xterm.Terminal; - currentTitle: string = "Terminal"; + currentTitle: State = van.state("Terminal"); del: () => void; dom: HTMLElement; private terminalId: string | null = null; @@ -20,7 +20,7 @@ export class Terminal implements Displayable { } title(): string { - return this.currentTitle; + return this.currentTitle.val; } constructor() { @@ -59,10 +59,13 @@ export class Terminal implements Displayable { this.unsubTerminalExit = window.electronAPI.onTerminalExit( this.terminalId, - (exitCode) => + (exitCode) => { this.term.writeln( - `\r\n[Process exited with code ${exitCode}]`, - ), + `\r\n[Process exited with code ${exitCode}]\n"Press any key to close..."`, + ); + + this.term.onData(() => this.close()); + }, ); // Handle user input @@ -72,6 +75,8 @@ export class Terminal implements Displayable { } }); + this.term.onTitleChange((title) => (this.currentTitle.val = title)); + // Set up resize handling this.resizeObserver = new ResizeObserver(() => { this.handleResize();