- Move the Terminal plugin into src/lib/features/terminal/ on the host Svelte runtime, with xterm 6.0.0 and addon-fit 0.11.0. - Buttons, shortcuts, Help rows, and the close guard follow the Terminal switch. The first use loads the module. - Add Settings → Terminal and the terminal settings section. The first start copies the old runestone.terminal key. - The 16 ANSI colors come from the --rs-ansi-* tokens. - Off asks first when a shell runs in any window (pty_running). - Rust: no pty-data or pty-exit events, an owner check for write, resize, and close, output joined up to 64 KiB or 8 ms, and the sessions of a reloaded page close. - Remove api.pty, the terminal contribution, TerminalSlot, and the plugin loader of the smoke harness. - Check only the tested switches in the Background smoke test. - Update the tests, the menu inventory, the docs, and UI-058.
40 lines
1.9 KiB
Svelte
40 lines
1.9 KiB
Svelte
<script lang="ts">
|
|
// The place of the terminal panel in the workbench and in the terminal window. It is in the main bundle.
|
|
// The first mount loads the Terminal feature (xterm included). An unmount closes the sessions of this panel.
|
|
import { onMount } from "svelte";
|
|
import { t } from "$lib/i18n";
|
|
import { terminalInstance, type TerminalAction, type TerminalMount, type TerminalProps } from "./terminalHost";
|
|
let props: TerminalProps = $props();
|
|
let container: HTMLDivElement;
|
|
let mounted = $state.raw<TerminalMount>();
|
|
let loading = $state(true);
|
|
let error = $state("");
|
|
let ready: Promise<TerminalMount | undefined> = Promise.resolve(undefined);
|
|
onMount(() => {
|
|
let disposed = false;
|
|
ready = terminalInstance().then(instance => {
|
|
if (disposed) return undefined;
|
|
mounted = instance.mountDock(container, { ...props });
|
|
return mounted;
|
|
}).catch(reason => { if (!disposed) error = String(reason); return undefined; }).finally(() => { loading = false; });
|
|
return () => {
|
|
disposed = true;
|
|
const current = mounted;
|
|
mounted = undefined;
|
|
void current?.dispose().catch(reason => console.error("The terminal panel did not close cleanly.", reason));
|
|
};
|
|
});
|
|
$effect(() => { mounted?.update({ ...props }); });
|
|
/** Run a terminal action. It waits for the first load. */
|
|
export async function command(action: Exclude<TerminalAction, "toggle">) { await (await ready)?.command(action); }
|
|
</script>
|
|
{#if error}<p class="error" role="alert">{$t("The terminal could not start: {error}", { error })}</p>{/if}
|
|
{#if loading}<p class="loading">{$t("Loading the terminal…")}</p>{/if}
|
|
<div class="terminal-host" bind:this={container}></div>
|
|
<style>
|
|
.terminal-host { display: flex; flex-direction: column; flex: 1; height: 100%; min-height: 0; min-width: 0; }
|
|
.error, .loading { margin: 0; padding: 7px 12px; font-size: 12px; }
|
|
.error { color: var(--rs-error); }
|
|
.loading { color: var(--rs-text-dim); }
|
|
</style>
|