Release RuneStone 0.1.4 with installable plugins and settings

This commit is contained in:
Knotty Wyvern
2026-10-04 15:05:51 -07:00
parent 0268c5c9f0
commit 6b7af0d527
82 changed files with 4150 additions and 212 deletions
+9 -1
View File
@@ -33,7 +33,14 @@
let { buffer, tabs, chrome, reading, focusLine, onChange, onRenameTitle, onInsertImage, onToggleReading, onToggleChrome, onOpenLink, onOpenWorkspace, onNewFile, onQuickOpen, hasWorkspace, tableActions }: Props = $props();
let previewMode = $state<"split" | "preview">("split");
let modeControls = $state<HTMLDivElement>();
let titleFocusId = $state<string | null>(null);
const shouldFocusOnMount = () => !modeControls?.contains(document.activeElement);
export function focusTitle(id: string) {
titleFocusId = id;
}
$effect(() => {
if (titleFocusId !== buffer?.id) titleFocusId = null;
});
const previewScroll = new Map<string, { top: number; left: number }>();
$effect(() => {
const ids = tabs.map(tab => tab.id);
@@ -131,7 +138,8 @@
<div class="editor-wrap" class:hidden={reading && canPreview && previewMode === "preview"}>
{#key buffer.id}
{#if !isIde && canPreview && !reading}
<LiveWriter {buffer} {onChange} {onRenameTitle} {onInsertImage} {onOpenLink} {focusLine} {tableActions} {shouldFocusOnMount} />
<LiveWriter {buffer} {onChange} {onRenameTitle} {onInsertImage} {onOpenLink} {focusLine} {tableActions} {shouldFocusOnMount}
focusTitle={titleFocusId === buffer.id} onTitleFocused={() => { titleFocusId = null; }} />
{:else}
<EditorHost {buffer} {chrome} {onChange} {onInsertImage} {focusLine} {tableActions} {shouldFocusOnMount} />
{/if}
+2
View File
@@ -1,4 +1,5 @@
<script lang="ts">
import { pluginHost } from "$lib/plugins/registry";
import { tick, type Snippet } from "svelte";
import { workspaceReadDataUrl } from "$lib/workspace/api";
import { markdownImages, renderMarkdownHtml, renderMarkdownSections, type MarkdownSection } from "$lib/workspace/noteHtml";
@@ -44,6 +45,7 @@
}
$effect(() => {
void $pluginHost;
const path = noteRel;
const text = contents;
let cancelled = false;
+184
View File
@@ -0,0 +1,184 @@
<script lang="ts">
import PluginManager from "$lib/plugins/PluginManager.svelte";
import { onMount, untrack } from "svelte";
import Icon from "$lib/ui/Icon.svelte";
import IconButton, { type IconName } from "$lib/ui/IconButton.svelte";
import { DEFAULT_SETTINGS, MIN_AUTOSAVE_SECONDS, MAX_AUTOSAVE_SECONDS, validAutosaveSeconds, type AppSettings } from "$lib/workspace/settings";
import { version, license } from "../../../package.json";
let { settings, help = false, onSave, onClose }: {
settings: AppSettings;
help?: boolean;
onSave: (value: AppSettings) => void;
onClose: () => void;
} = $props();
type Section = "general" | "plugins" | "about";
const sections: { id: Section; label: string; icon: IconName; keywords: string }[] = [
{ id: "general", label: "General", icon: "settings", keywords: "auto-save autosave save interval seconds files" },
{ id: "plugins", label: "Plug-ins", icon: "puzzle", keywords: "plugins extensions community" },
{ id: "about", label: "Help and about", icon: "help", keywords: "help about version shortcuts keyboard guide" },
];
let section = $state<Section>(untrack(() => help ? "about" : "general"));
let query = $state("");
let seconds = $state<number | undefined>(untrack(() => settings.autosaveSeconds));
let message = $state("");
let error = $state("");
let dialog: HTMLDialogElement;
const matches = $derived(sections.filter(item => `${item.label} ${item.keywords}`.toLowerCase().includes(query.trim().toLowerCase())));
const selected = $derived(matches.find(item => item.id === section) ?? matches[0]);
$effect(() => { seconds = settings.autosaveSeconds; });
onMount(() => {
const previous = document.activeElement instanceof HTMLElement ? document.activeElement : null;
dialog.showModal();
return () => { dialog.close(); previous?.focus(); };
});
function apply(value: AppSettings) {
error = "";
try { onSave(value); message = "Changes saved."; }
catch { error = "Could not save these settings. Your previous settings still apply. Try again."; message = ""; }
}
function changeInterval() {
if (!validAutosaveSeconds(seconds)) {
error = "Choose a whole number from 1 to 300 seconds.";
message = "";
return;
}
apply({ ...settings, autosaveSeconds: seconds });
}
function select(next: Section) { section = next; error = ""; message = ""; seconds = settings.autosaveSeconds; }
function trapFocus(event: KeyboardEvent) {
if (event.target instanceof Element && event.target.closest("dialog") !== dialog) return;
if (event.key !== "Tab") return;
const controls = [...dialog.querySelectorAll<HTMLElement>("button:not(:disabled), input:not(:disabled), summary")]
.filter(element => element.getClientRects().length > 0);
const first = controls[0], last = controls.at(-1);
if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last?.focus(); }
else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first?.focus(); }
}
</script>
<dialog bind:this={dialog} class:help aria-labelledby="settings-title" onkeydown={trapFocus} oncancel={event => { if (event.target === dialog) { event.preventDefault(); onClose(); } }}>
<header>
<h1 id="settings-title">{help ? "Help and about" : "Settings"}</h1>
<IconButton icon="close" label={help ? "Close help" : "Close settings"} onclick={onClose} />
</header>
<div class="body">
{#if !help}
<aside>
<label class="search"><Icon icon="search" /><input aria-label="Search settings" placeholder="Search settings…" bind:value={query} /></label>
<p class="nav-heading">Preferences</p>
<nav aria-label="Settings categories">
{#each matches as item}
<button class:active={selected?.id === item.id} aria-current={selected?.id === item.id ? "page" : undefined} onclick={() => select(item.id)}><Icon icon={item.icon} />{item.label}</button>
{/each}
</nav>
<p class="scope">For all workspaces on this device.</p>
</aside>
{/if}
<div class="content">
{#if !selected}
<h2>No settings found</h2>
<p>Try “save”, “plug-ins”, or “help”.</p>
<button class="text-button" onclick={() => query = ""}>Clear search</button>
{:else if selected.id === "general"}
<h2>General</h2>
<p class="intro">Choose how RuneStone saves your work.</p>
<h3>Files</h3>
<div class="card">
<div class="setting-row">
<div><label for="autosave-enabled">Auto-save</label><p id="autosave-description">Save changed notes and scripts, including background tabs.</p></div>
<input id="autosave-enabled" class="switch" type="checkbox" role="switch" aria-describedby="autosave-description" checked={settings.autosaveEnabled} onchange={event => { apply({ ...settings, autosaveEnabled: event.currentTarget.checked }); event.currentTarget.checked = settings.autosaveEnabled; }} />
</div>
<div class="setting-row">
<div><label for="autosave-seconds">Auto-save interval</label><p id="interval-description">Time between saves, even while you type. Choose 1–300 seconds.</p></div>
<div class="interval"><input id="autosave-seconds" type="number" min={MIN_AUTOSAVE_SECONDS} max={MAX_AUTOSAVE_SECONDS} step="1" required disabled={!settings.autosaveEnabled} aria-describedby="interval-description" aria-invalid={!!error} bind:value={seconds} onchange={changeInterval} /><span>seconds</span></div>
</div>
</div>
<p class="note">{settings.autosaveEnabled ? "Only changed files are saved." : "Auto-save is off. Use Ctrl+S to save your changes."} Disk conflicts keep your edits for review.</p>
<div class="section-footer"><button class="text-button" onclick={() => { seconds = DEFAULT_SETTINGS.autosaveSeconds; apply({ ...DEFAULT_SETTINGS }); }}>Restore defaults</button><span>Default: every 5 seconds</span></div>
{#if error}<p class="error" role="alert">{error}</p>{/if}
<p class="saved" role="status">{message}</p>
{:else if selected.id === "plugins"}
<PluginManager />
{:else}
<div class="brand"><img src="/runestone.svg" alt="" width="88" height="88" /><h2>RuneStone</h2><p>Version {version}</p></div>
<div class="card help-card">
<details open><summary><Icon icon="book-open" /> Get started</summary><div class="help-copy"><p>Use the folder button to open a workspace or create one. Your notes and scripts stay as ordinary files on disk.</p><p>Use the + beside the tabs for a new tab. Press Ctrl+N to create a file, or Ctrl+P to find one.</p><p>Press Ctrl+E to switch between writing and source editing. Use the terminal button to work with a shell beside your files.</p></div></details>
<details><summary><Icon icon="save" /> Save your work</summary><div class="help-copy"><p>Auto-save saves changed files at the interval in Settings → General. Ctrl+S saves the active file immediately.</p><p>If another app changes a file, RuneStone keeps your edits and offers both versions for review.</p></div></details>
<details><summary><Icon icon="code" /> Keyboard shortcuts</summary><dl><div><dt>Open a workspace</dt><dd><kbd>Ctrl+O</kbd></dd></div><div><dt>Find a file</dt><dd><kbd>Ctrl+P</kbd></dd></div><div><dt>Save the active file</dt><dd><kbd>Ctrl+S</kbd></dd></div><div><dt>Search the workspace</dt><dd><kbd>Ctrl+Shift+F</kbd></dd></div><div><dt>Open settings</dt><dd><kbd>Ctrl+,</kbd></dd></div><div><dt>Help and about</dt><dd><kbd>F1</kbd></dd></div></dl></details>
</div>
<p class="about-note">RuneStone is under development. Maintained by kwyvern-gh.</p>
{/if}
</div>
</div>
</dialog>
<style>
dialog { width: min(920px, calc(100vw - 32px)); height: min(650px, calc(100dvh - 32px)); max-width: none; max-height: none; padding: 0; background: var(--rs-bg); color: var(--rs-text); border: 1px solid var(--rs-border); border-radius: 12px; box-shadow: 0 24px 80px #0008; overflow: hidden; }
dialog::backdrop { background: #0008; }
dialog.help { width: min(650px, calc(100vw - 32px)); }
header { height: 48px; padding: 0 14px 0 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--rs-border); background: var(--rs-bg-elevated); }
h1 { font-size: 14px; font-weight: 600; margin: 0; }
.body { display: flex; height: calc(100% - 48px); }
aside { width: 220px; flex-shrink: 0; padding: 18px 12px; background: var(--rs-bg-elevated); border-right: 1px solid var(--rs-border); display: flex; flex-direction: column; overflow: auto; }
.search { display: flex; gap: 7px; align-items: center; background: var(--rs-bg-active); border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); padding: 8px; color: var(--rs-text-dim); }
.search:focus-within { outline: 2px solid var(--rs-accent); }
.search input { width: 100%; min-width: 0; border: 0; padding: 0; outline: none; background: transparent; color: var(--rs-text); }
.nav-heading { margin: 24px 10px 8px; font-size: 11px; color: var(--rs-text-dim); }
nav { display: flex; flex-direction: column; gap: 4px; }
nav button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border: 0; border-radius: var(--rs-control-radius); background: transparent; text-align: left; }
nav button:hover { background: var(--rs-bg-active); }
nav button.active { background: var(--rs-item-selection-bg); box-shadow: inset 0 0 0 var(--rs-item-selection-width) var(--rs-item-selection-border); border-radius: var(--rs-item-selection-radius); }
.scope { margin: auto 10px 0; padding-top: 24px; color: var(--rs-text-dim); font-size: 12px; }
.content { padding: 30px 32px; flex: 1; min-width: 0; overflow-y: auto; }
h2 { margin: 0; font-size: 23px; font-weight: 600; color: var(--rs-text-strong); }
h3 { margin: 28px 0 12px; font-size: 14px; font-weight: 600; }
p { color: var(--rs-text-dim); line-height: 1.6; }
.intro { margin: 7px 0 24px; }
.card { padding: 0 20px; background: var(--rs-bg-elevated); border: 1px solid var(--rs-border); border-radius: 10px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 22px 0; }
.setting-row + .setting-row { border-top: 1px solid var(--rs-border); }
.setting-row label { font-weight: 500; }
.setting-row p { margin: 5px 0 0; font-size: 12px; }
.switch { appearance: none; width: 38px; height: 22px; flex: 0 0 38px; margin: 0; border-radius: 20px; background: var(--rs-bg-active); border: 1px solid var(--rs-text-dim); cursor: pointer; }
.switch::before { content: ""; display: block; width: 16px; height: 16px; margin: 2px; background: var(--rs-text); border-radius: 50%; transition: transform .12s; }
.switch:checked { background: var(--rs-accent); border-color: var(--rs-accent); }
.switch:checked::before { transform: translateX(16px); background: var(--rs-bg); }
.interval { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; font-size: 11px; color: var(--rs-text-dim); }
.interval input { width: 84px; padding: 9px; border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); background: var(--rs-bg); color: var(--rs-text); font-size: 14px; }
.interval input:disabled { opacity: .45; }
.note, .section-footer, .about-note { font-size: 12px; }
.note { margin: 16px 0 24px; }
.section-footer { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; color: var(--rs-text-dim); }
.text-button { border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); background: var(--rs-bg-elevated); padding: 8px 12px; color: var(--rs-text); }
.text-button:hover { background: var(--rs-bg-active); }
.saved { font-size: 12px; color: var(--rs-ok); min-height: 20px; }
.error { color: var(--rs-error); }
.brand { text-align: center; margin-bottom: 26px; }
.brand h2 { font-size: 28px; margin-top: 4px; }
.brand p { margin: 6px 0; font-size: 12px; }
.help-card details + details { border-top: 1px solid var(--rs-border); }
summary { display: flex; align-items: center; gap: 12px; padding: 18px 0; cursor: pointer; list-style: none; border-radius: var(--rs-control-radius); }
summary::after { content: "+"; margin-left: auto; color: var(--rs-text-dim); }
details[open] summary::after { content: "−"; }
.help-copy, dl { margin: 0 0 18px 28px; font-size: 12px; }
.help-copy p:first-child { margin-top: 0; }
dl div { display: flex; justify-content: space-between; gap: 12px; margin: 10px 0; }
dd { margin: 0; }
kbd { font-family: var(--rs-font-mono); color: var(--rs-text-dim); }
.about-note { text-align: center; margin: 20px 0 0; }
@media (max-width: 660px) {
.body { flex-direction: column; }
aside { width: 100%; padding: 12px; border-right: 0; border-bottom: 1px solid var(--rs-border); flex-shrink: 0; }
nav { flex-direction: row; margin-top: 10px; }
nav button { width: auto; flex: 1; padding: 8px; gap: 6px; }
.nav-heading, .scope { display: none; }
.content { padding: 24px 18px; }
.setting-row { gap: 14px; }
}
</style>
-260
View File
@@ -1,260 +0,0 @@
<script lang="ts">
import { onMount, tick } from "svelte";
import IconButton from "$lib/ui/IconButton.svelte";
import { actionMenu, type ActionMenuItem } from "$lib/ui/actionMenu";
import { ptyProfiles, ptyNewWindow, ptyDictation, workspaceRead } from "$lib/workspace/api";
import { directoryCommand, fileCommand, parseTasks, readSettings, remember, type ShellProfile, type TerminalControl, type TerminalSettings as Settings } from "$lib/terminal/model";
import TerminalPicker from "$lib/terminal/TerminalPicker.svelte";
import TerminalSettings from "$lib/terminal/TerminalSettings.svelte";
import TerminalPane from "./TerminalPane.svelte";
type Session = { id: string; group: string; title: string; state: string; profile: ShellProfile; directory: string; weight: number; command?: string };
type Picker = { title: string; items: { label: string; detail?: string; value: string }[]; onPick: (value: string) => void; empty?: string };
let { cwd, visible, maximized = false, standalone = false, onClose, onMaximize = () => {}, activeFile = false, onRunFile, getSelection = () => "", onConfigureTasks }: {
cwd: string; visible: boolean; maximized?: boolean; standalone?: boolean; onClose: () => void; onMaximize?: () => void;
activeFile?: boolean; onRunFile?: () => Promise<string | null>; getSelection?: () => string; onConfigureTasks?: () => Promise<void>;
} = $props();
let sessions = $state<Session[]>([]);
let profiles = $state<ShellProfile[]>([]);
let settings = $state(readSettings());
let activeId = $state("");
let loading = $state(true);
let error = $state("");
let railWidth = $state(205);
let picker = $state<Picker | null>(null);
let showSettings = $state(false);
let recentCommands = $state<string[]>([]);
let recentDirectories = $state<string[]>([]);
let menu: HTMLElement | undefined;
let menuAnchor: HTMLElement | undefined;
let profileAnchor: HTMLDivElement;
let moreAnchor: HTMLDivElement;
let panes: HTMLDivElement;
let sequence = 0;
let stopResize: (() => void) | undefined;
let ready: Promise<void> = Promise.resolve();
const controls = new Map<string, TerminalControl>();
const active = $derived(sessions.find(session => session.id === activeId));
const group = $derived(sessions.filter(session => session.group === active?.group));
const totalWeight = $derived(group.reduce((sum, session) => sum + session.weight, 0));
function report(reason: unknown) { error = String(reason); }
function persist(next: Settings) {
settings = { ...next };
try { localStorage.setItem("runestone.terminal", JSON.stringify(settings)); } catch (reason) { report(reason); }
}
function defaultProfile() { return profiles.find(profile => profile.id === settings.defaultProfile) || profiles.find(profile => profile.kind !== "node") || profiles[0]; }
export function addSession(profile = defaultProfile(), split = false, command?: string, title?: string) {
if (!profile) return;
const id = crypto.randomUUID();
const next = { id, group: split && active ? active.group : id, title: title || `${profile.title} ${++sequence}`, state: "Starting", profile,
directory: split && active ? active.directory : cwd, weight: 1, command };
if (split) for (const member of group) member.weight = 1;
sessions = [...sessions, next]; activeId = id;
recentDirectories = remember(recentDirectories, next.directory);
}
function killSession(id: string) {
const previous = sessions.findIndex(session => session.id === id);
const sibling = sessions.find(session => session.group === sessions[previous]?.group && session.id !== id);
sessions = sessions.filter(session => session.id !== id);
if (activeId === id) activeId = sibling?.id || sessions[Math.max(0, previous - 1)]?.id || "";
void tick().then(() => controls.get(activeId)?.focus());
}
function select(id: string) { activeId = id; }
function closeMenu(focus = false) { menu?.remove(); menu = undefined; if (focus) menuAnchor?.querySelector<HTMLButtonElement>("button")?.focus(); }
function showMenu(anchor: HTMLElement, items: ActionMenuItem[], name: string) {
const same = menu && menuAnchor === anchor; closeMenu(); if (same) return;
menuAnchor = anchor;
const wrap = (entries: ActionMenuItem[]): ActionMenuItem[] => entries.map(item => "separator" in item ? item : { ...item,
children: item.children ? wrap(item.children) : undefined,
run: item.run ? () => { closeMenu(); item.run?.(); } : undefined });
const bounds = anchor.getBoundingClientRect();
menu = actionMenu(bounds.right - 430, bounds.bottom + 4, wrap(items), () => closeMenu(true), name);
}
function profileMenu() {
showMenu(profileAnchor, [
{ label: "New Terminal", icon: "plus", shortcut: "Ctrl+Shift+`", run: () => addSession() },
{ label: "New Terminal Window", icon: "external", shortcut: "Ctrl+Shift+Alt+`", run: () => void ptyNewWindow().catch(report) },
{ label: "Split Terminal", icon: "column", shortcut: "Ctrl+Shift+5", disabled: !active, run: () => addSession(active?.profile, true) },
{ separator: true },
...profiles.map(profile => ({ label: profile.title, icon: "code" as const, title: profile.kind === "node" ? "Node.js REPL with a local inspector. Attach using an external debugger." : undefined, run: () => addSession(profile) })),
{ label: "Split Terminal with Profile", icon: "column", disabled: !active, children: profiles.map(profile => ({ label: profile.title, icon: "code", run: () => addSession(profile, true) })) },
{ separator: true },
{ label: "Configure Terminal Settings", icon: "format", run: () => showSettings = true },
{ label: "Select Default Profile", icon: "select", run: () => picker = { title: "Select default terminal profile", items: profiles.filter(profile => profile.kind !== "node").map(profile => ({ label: profile.title, value: profile.id, detail: profile.id === settings.defaultProfile ? "Default" : undefined })), onPick: value => persist({ ...settings, defaultProfile: value }) } },
{ separator: true },
{ label: "Run Task…", icon: "task", run: () => void runTask() },
{ label: "Configure Tasks…", icon: "code", disabled: !onConfigureTasks, run: () => void onConfigureTasks?.().catch(report) },
], "Terminal profiles");
}
async function runFile() {
const target = active;
if (!target || !onRunFile) return;
try { const path = await onRunFile(); if (path) controls.get(target.id)?.send(fileCommand(path, target.profile.kind)); } catch (reason) { report(reason); }
}
function runSelection() {
const text = getSelection();
if (!text) { error = "Select text in the editor first."; return; }
controls.get(activeId)?.send(text);
}
function historyPicker(kind: "commands" | "directories") {
const target = active;
if (!target) return;
picker = { title: kind === "commands" ? "Run recent command" : "Go to recent directory",
items: (kind === "commands" ? recentCommands : recentDirectories).map(value => ({ label: value, value })),
empty: kind === "commands" ? "No commands yet. Shell commands appear after the next prompt." : "No directories yet.",
onPick: value => { try { controls.get(target.id)?.send(kind === "commands" ? value : directoryCommand(value, target.profile.kind)); } catch (reason) { report(reason); } } };
}
async function runTask() {
try {
const tasks = parseTasks(await workspaceRead(".runestone/tasks.json"));
picker = { title: "Run task", items: tasks.map((task, index) => ({ label: task.label, detail: task.command, value: String(index) })), empty: "No tasks configured. Choose Configure Tasks… to add one.", onPick: index => {
const task = tasks[Number(index)];
const profile = task.profile ? profiles.find(profile => profile.id === task.profile) : defaultProfile();
if (!profile) { error = `Task profile is unavailable: ${task.profile}`; return; }
addSession(profile, false, task.command, task.label);
} };
} catch (reason) { error = `Cannot load .runestone/tasks.json. Use Configure Tasks… to create or edit it. ${String(reason)}`; }
}
function moreMenu() {
showMenu(moreAnchor, [
{ label: "Scroll to Previous Command", icon: "up", shortcut: "Ctrl+UpArrow", disabled: !active, run: () => controls.get(activeId)?.scrollCommand(-1) },
{ label: "Scroll to Next Command", icon: "down", shortcut: "Ctrl+DownArrow", disabled: !active, run: () => controls.get(activeId)?.scrollCommand(1) },
{ label: "Clear Terminal", icon: "clear", disabled: !active, run: () => controls.get(activeId)?.clear() },
{ label: "Run Active File", icon: "code", disabled: !active || !activeFile, run: () => void runFile() },
{ label: "Run Selected Text", icon: "select", disabled: !active || !activeFile, run: runSelection },
{ label: "Start Dictation", icon: "comment", disabled: !active, title: "Start Windows voice typing in the focused terminal", run: () => { controls.get(activeId)?.focus(); void ptyDictation().catch(report); } },
{ separator: true },
{ label: "Go to Recent Directory…", icon: "external", shortcut: "Ctrl+G", disabled: !active, run: () => historyPicker("directories") },
{ label: "Run Recent Command…", icon: "task", shortcut: "Ctrl+Alt+R", disabled: !active, run: () => historyPicker("commands") },
], "Terminal actions");
}
export async function command(action: "new" | "split" | "window" | "previous" | "next" | "commands" | "directories") {
await ready;
if (action === "new") addSession();
else if (action === "split") addSession(active?.profile || defaultProfile(), !!active);
else if (action === "window") void ptyNewWindow().catch(report);
else if (action === "previous" || action === "next") controls.get(activeId)?.scrollCommand(action === "previous" ? -1 : 1);
else historyPicker(action);
}
function beginResize(event: PointerEvent, update: (x: number) => void) {
if (event.button !== 0) return;
event.preventDefault(); stopResize?.();
const move = (event: PointerEvent) => update(event.clientX);
stopResize = () => { window.removeEventListener("pointermove", move); window.removeEventListener("pointerup", stop); window.removeEventListener("pointercancel", stop); stopResize = undefined; };
const stop = () => stopResize?.();
window.addEventListener("pointermove", move); window.addEventListener("pointerup", stop); window.addEventListener("pointercancel", stop);
}
function resizeRail(event: PointerEvent) { const x = event.clientX, width = railWidth; beginResize(event, next => railWidth = Math.min(340, Math.max(140, width + x - next))); }
function resizeSplit(event: PointerEvent, session: Session) {
const index = group.indexOf(session), previous = group[index - 1];
if (!previous) return;
const x = event.clientX, before = previous.weight, after = session.weight, width = panes.clientWidth, total = totalWeight;
beginResize(event, next => { const change = (next - x) / width * total; previous.weight = Math.min(before + after - .15, Math.max(.15, before + change)); session.weight = before + after - previous.weight; });
}
function paneLeft(session: Session) { return group.slice(0, group.indexOf(session)).reduce((sum, item) => sum + item.weight, 0) / totalWeight * 100; }
onMount(() => {
let disposed = false;
ready = ptyProfiles().then(found => {
if (disposed) return;
profiles = found;
if (!profiles.some(profile => profile.id === settings.defaultProfile)) settings.defaultProfile = defaultProfile()?.id || "";
if (profiles.length) addSession(); else error = "No supported shells were found on PATH.";
}).catch(report).finally(() => loading = false);
const outside = (event: PointerEvent) => { if (menu && !menu.contains(event.target as Node) && !menuAnchor?.contains(event.target as Node)) closeMenu(); };
const resize = () => closeMenu();
window.addEventListener("pointerdown", outside); window.addEventListener("resize", resize);
return () => { disposed = true; closeMenu(); stopResize?.(); window.removeEventListener("pointerdown", outside); window.removeEventListener("resize", resize); };
});
$effect(() => { if (!visible) { closeMenu(); picker = null; showSettings = false; } });
</script>
<div class="dock" style:--rail="{railWidth}px">
<header class="ribbon">
<span class="label" title={cwd}>Terminal</span><span class="directory" title={active?.directory || cwd}>{active?.directory || cwd}</span>
<div class="actions">
{#if sessions.length === 1}<span class="single-session" title={`${active?.title} · ${active?.state}`}>{active?.profile.title}</span>{/if}
<IconButton icon="plus" label="New terminal" disabled={loading || !profiles.length} onclick={() => addSession()} />
<div bind:this={profileAnchor}><IconButton icon="chevron-down" label="Terminal profiles and tasks" disabled={loading} onclick={profileMenu} /></div>
<IconButton icon="split" label="Split terminal (Ctrl+Shift+5)" disabled={!active} onclick={() => addSession(active?.profile, true)} />
<div bind:this={moreAnchor}><IconButton icon="more" label="More terminal actions" onclick={moreMenu} /></div>
<IconButton icon="trash" label="Kill terminal" disabled={!active} onclick={() => killSession(activeId)} />
{#if !standalone}<IconButton icon={maximized ? "restore" : "maximize"} label={maximized ? "Restore panel" : "Maximize panel"} onclick={onMaximize} />{/if}
<IconButton icon="close" label={standalone ? "Close terminal window" : "Hide terminal (sessions keep running)"} onclick={onClose} />
</div>
</header>
{#if error}<div class="error" role="alert"><span>{error}</span><button aria-label="Dismiss terminal error" onclick={() => error = ""}>×</button></div>{/if}
<div class="body">
<div class="panes" bind:this={panes}>
{#each sessions as session (session.id)}
<div class="pane" class:shown={session.group === active?.group} class:focused={session.id === activeId}
style:left="{session.group === active?.group ? paneLeft(session) : 0}%" style:width="{session.group === active?.group ? session.weight / totalWeight * 100 : 100}%">
{#if group.length > 1 && session.group === active?.group}<div class="pane-label">{session.title}</div>{/if}
<TerminalPane id={session.id} {cwd} directory={session.directory} profile={session.profile} {settings}
active={visible && session.group === active?.group} focused={session.id === activeId} onFocus={() => activeId = session.id}
onState={state => { session.state = state; if (state === "Running" && session.command) { controls.get(session.id)?.send(session.command); session.command = undefined; } }}
onControl={control => { if (control) controls.set(session.id, control); else controls.delete(session.id); }}
onCommand={command => recentCommands = remember(recentCommands, command)}
onDirectory={directory => { session.directory = directory; recentDirectories = remember(recentDirectories, directory); }} />
{#if session.group === active?.group && group.indexOf(session) > 0}
<div class="split-gutter" role="separator" aria-label="Resize split terminals" aria-orientation="vertical" onpointerdown={event => resizeSplit(event, session)}></div>
{/if}
</div>
{/each}
{#if !sessions.length}<div class="empty"><p>{loading ? "Detecting terminal profiles…" : "No terminal sessions."}</p><button disabled={loading || !profiles.length} onclick={() => addSession()}>Start a terminal</button></div>{/if}
</div>
{#if sessions.length > 1}
<div class="gutter" role="separator" aria-orientation="vertical" aria-label="Resize terminal list" onpointerdown={resizeRail}></div>
<nav class="rail" aria-label="Terminal list">
{#each sessions as session (session.id)}
<div class="item" data-session={session.id} class:active={session.id === activeId} class:grouped={sessions.filter(item => item.group === session.group).length > 1}>
<button class="pick" aria-pressed={session.id === activeId} title={`${session.title} · ${session.state} · ${session.directory}`} onclick={() => select(session.id)}
onkeydown={event => {
if (event.key === "Delete") { event.preventDefault(); killSession(session.id); }
if (event.key === "ArrowDown" || event.key === "ArrowUp") { event.preventDefault(); const next = sessions[(sessions.indexOf(session) + (event.key === "ArrowDown" ? 1 : sessions.length - 1)) % sessions.length]; activeId = next.id; (event.currentTarget.closest("nav")?.querySelector(`[data-session="${next.id}"] .pick`) as HTMLButtonElement)?.focus(); }
}}><span class="shell-icon" aria-hidden="true">›_</span><span class="session-name">{session.title}<small>{session.state}</small></span></button>
<div class="row-actions">
<IconButton icon="split" label={`Split ${session.title}`} onclick={() => { activeId = session.id; addSession(session.profile, true); }} />
<IconButton icon="trash" label={`Kill ${session.title} (Del)`} onclick={() => killSession(session.id)} />
</div>
</div>
{/each}
</nav>
{/if}
</div>
</div>
{#if picker}<TerminalPicker {...picker} onClose={() => picker = null} />{/if}
{#if showSettings}<TerminalSettings {settings} {profiles} onSave={persist} onClose={() => showSettings = false} />{/if}
<style>
.dock { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.ribbon { display: flex; align-items: center; gap: 10px; flex: 0 0 36px; padding: 0 8px; background: var(--rs-bg-elevated); }
.label { font-size: 13px; color: var(--rs-text-strong); }
.directory { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--rs-text-dim); font-size: 12px; }
.actions, .row-actions { display: flex; align-items: center; flex-shrink: 0; }
.single-session { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--rs-text-dim); margin-right: 6px; }
.body { display: flex; flex: 1; min-height: 0; }
.panes { flex: 1; position: relative; min-width: 0; min-height: 0; }
.pane { display: flex; flex-direction: column; position: absolute; top: 0; bottom: 0; visibility: hidden; min-width: 0; overflow: hidden; }
.pane.shown { visibility: visible; }
.pane :global(.term) { flex: 1; min-height: 0; height: auto; }
.pane-label { flex: 0 0 23px; padding: 3px 10px; font-size: 11px; color: var(--rs-text-dim); border-top: 1px solid transparent; }
.focused .pane-label { color: var(--rs-text-strong); border-top-color: var(--rs-accent); }
.split-gutter { position: absolute; top: 0; bottom: 0; left: 0; width: 4px; cursor: col-resize; background: var(--rs-border); }
.gutter { flex: 0 0 4px; cursor: col-resize; }
.gutter:hover, .split-gutter:hover { background: var(--rs-accent); }
.rail { flex: 0 0 var(--rail); width: var(--rail); overflow: auto; padding: 4px; border-left: 1px solid var(--rs-border); }
.item { display: flex; align-items: center; min-width: 0; border-left: 2px solid transparent; }
.item.grouped { border-left-color: var(--rs-border); }
.item.active { background: var(--rs-bg-active); border-left-color: var(--rs-accent); }
.pick { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; border: 0; background: transparent; text-align: left; padding: 5px; }
.shell-icon { color: var(--rs-text-dim); }
.session-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
small { display: block; font-size: 10px; color: var(--rs-text-dim); }
.row-actions { visibility: hidden; }
.item:hover .row-actions, .item:focus-within .row-actions, .item.active .row-actions { visibility: visible; }
.error { padding: 7px 12px; display: flex; align-items: center; gap: 8px; color: var(--rs-error); font-size: 12px; border-bottom: 1px solid var(--rs-border); }
.error span { flex: 1; }
.error button, .empty button { background: var(--rs-bg-active); border: 1px solid var(--rs-border); padding: 4px 8px; }
.empty { padding: 20px; color: var(--rs-text-dim); }
@media (max-width: 700px) { .rail { flex-basis: 150px; width: 150px; } .row-actions { display: none; } .directory, .single-session { display: none; } .label { flex: 1; } }
</style>
-218
View File
@@ -1,218 +0,0 @@
<script lang="ts">
import { listen } from "@tauri-apps/api/event";
import { FitAddon } from "@xterm/addon-fit";
import { Terminal } from "@xterm/xterm";
import { onMount } from "svelte";
import { ptyClose, ptyOpen, ptyResize, ptyWrite } from "$lib/workspace/api";
import { terminalShortcut, type ShellProfile, type TerminalControl, type TerminalSettings } from "$lib/terminal/model";
import "@xterm/xterm/css/xterm.css";
type Props = {
id: string;
cwd: string;
active: boolean;
focused: boolean;
profile: ShellProfile;
directory: string;
settings: TerminalSettings;
onFocus: () => void;
onControl: (control: TerminalControl | null) => void;
onCommand: (command: string) => void;
onDirectory: (directory: string) => void;
onState: (state: string) => void;
};
let { id, cwd, active, focused, profile, directory, settings, onFocus, onControl, onCommand, onDirectory, onState }: Props = $props();
let host: HTMLDivElement | undefined = $state();
let focusTerminal: (() => void) | undefined = $state();
let instance = $state.raw<Terminal>();
let resizeTerminal: (() => void) | undefined;
$effect(() => { if (active && focused && !document.activeElement?.closest(".rail")) focusTerminal?.(); });
$effect(() => {
if (instance) {
instance.options.fontSize = settings.fontSize;
instance.options.scrollback = settings.scrollback;
instance.options.cursorBlink = settings.cursorBlink;
requestAnimationFrame(() => resizeTerminal?.());
}
});
onMount(() => {
if (!host) {
return;
}
const term = new Terminal({
scrollback: settings.scrollback,
fontFamily: "Cascadia Code, Cascadia Mono, Consolas, monospace",
fontSize: settings.fontSize,
cursorBlink: settings.cursorBlink,
allowProposedApi: true,
theme: {
background: "#141414",
foreground: "#e6e6e6",
cursor: "#82aaff",
selectionBackground: "#264f78",
black: "#3b4252",
red: "#bf616a",
green: "#a3be8c",
yellow: "#ebcb8b",
blue: "#81a1c1",
magenta: "#b48ead",
cyan: "#88c0d0",
white: "#e5e9f0",
},
});
const fit = new FitAddon();
term.loadAddon(fit);
term.open(host);
instance = term;
term.attachCustomKeyEventHandler(event => !terminalShortcut(event));
let disposed = false;
let opened = false;
let exited = false;
const pendingInput: string[] = [];
let writes = Promise.resolve();
const unlisteners: (() => void)[] = [];
const fail = (err: unknown) => {
if (!disposed) term.writeln(`\r\n${String(err)}`);
};
const resize = () => {
if (disposed || !host?.clientWidth || !host?.clientHeight) return;
fit.fit();
if (opened && !exited) void ptyResize(id, term.cols, term.rows).catch(fail);
};
resizeTerminal = resize;
focusTerminal = () => { resize(); term.focus(); };
const send = (data: string) => {
if (exited || disposed) return;
if (!opened) { pendingInput.push(data); return; }
writes = writes.then(() => ptyWrite(id, data)).catch(fail);
};
const onData = term.onData(send);
let markers: import("@xterm/xterm").IMarker[] = [];
let prompt: { marker: import("@xterm/xterm").IMarker; column: number } | undefined;
const promptParser = term.parser.registerOscHandler(133, data => {
if (data === "A") {
const marker = term.registerMarker(0);
if (marker) markers = [...markers.filter(item => !item.isDisposed), marker].slice(-1000);
}
if (data === "B") {
prompt?.marker.dispose();
const marker = term.registerMarker(0);
prompt = marker ? { marker, column: term.buffer.active.cursorX } : undefined;
}
return true;
});
const integration = term.parser.registerOscHandler(633, data => {
const separator = data.indexOf(";");
const type = data.slice(0, separator), value = data.slice(separator + 1);
try {
if (type === "Cwd") onDirectory(value);
if (type === "RSCwd" || type === "RSCommand") {
const decoded = new TextDecoder().decode(Uint8Array.from(atob(value), char => char.charCodeAt(0)));
if (type === "RSCwd") onDirectory(decoded); else onCommand(decoded);
}
} catch { /* Ignore malformed shell integration output. */ }
return true;
});
const keys = term.onKey(({ domEvent }) => {
if (profile.kind !== "cmd" || domEvent.key !== "Enter" || !prompt || prompt.marker.isDisposed) return;
const buffer = term.buffer.active;
let command = "";
for (let line = prompt.marker.line; line <= buffer.baseY + buffer.cursorY; line++) {
command += buffer.getLine(line)?.translateToString(true, line === prompt.marker.line ? prompt.column : 0) || "";
}
if (command.trim()) onCommand(command);
prompt.marker.dispose(); prompt = undefined;
});
onControl({
focus: () => { resize(); term.focus(); },
clear: () => { markers.forEach(marker => marker.dispose()); markers = []; term.clear(); term.focus(); },
scrollCommand: direction => {
const lines = markers.filter(marker => !marker.isDisposed).map(marker => marker.line);
const current = term.buffer.active.viewportY;
const target = direction < 0 ? lines.reverse().find(line => line < current) : lines.find(line => line > current);
if (target !== undefined) term.scrollToLine(target); else if (direction > 0) term.scrollToBottom();
},
send: (text, execute = true) => {
if (exited) return;
term.paste(text.replace(/\r?\n/g, "\r"));
if (execute) send("\r");
term.focus();
},
});
const start = async () => {
try {
// Subscribe before spawning: shells and agents can print immediately.
const offData = await listen<{ id: string; data: number[] }>("pty-data", (event) => {
if (!disposed && event.payload.id === id) term.write(new Uint8Array(event.payload.data));
});
unlisteners.push(offData);
if (disposed) return;
const offExit = await listen<{ id: string; code: number | null }>("pty-exit", (event) => {
if (!disposed && event.payload.id === id) {
exited = true;
onState(`Exited${event.payload.code === null ? "" : ` (${event.payload.code})`}`);
term.writeln(`\r\n[Process exited${event.payload.code === null ? "" : ` with code ${event.payload.code}`} ]`);
}
});
unlisteners.push(offExit);
if (disposed) return;
resize();
await ptyOpen(id, term.cols, term.rows, cwd, profile.id, directory);
opened = true;
if (disposed) { await ptyClose(id); return; }
// Includes xterm's replies to startup cursor-position queries.
for (const data of pendingInput.splice(0)) {
writes = writes.then(() => ptyWrite(id, data)).catch(fail);
}
if (!exited) onState("Running");
resize();
if (active && focused) term.focus();
} catch (err) {
fail(err);
if (!disposed) onState("Failed");
} finally {
if (disposed) unlisteners.splice(0).forEach((off) => off());
}
};
void start();
const observer = new ResizeObserver(resize);
observer.observe(host);
return () => {
disposed = true;
focusTerminal = undefined;
instance = undefined;
resizeTerminal = undefined;
onControl(null);
observer.disconnect();
onData.dispose();
promptParser.dispose(); integration.dispose(); keys.dispose();
unlisteners.splice(0).forEach((off) => off());
if (opened) void ptyClose(id).catch(() => {});
term.dispose();
};
});
</script>
<div class="term" data-cwd={directory} bind:this={host} onfocusin={onFocus}></div>
<style>
.term {
height: 100%;
min-height: 0;
padding: 4px;
background: #141414;
}
.term :global(.xterm),
.term :global(.xterm-viewport) {
height: 100%;
}
.term :global(.xterm-viewport) {
/* Whole terminal rows can leave a gap above the bottom edge. */
background-color: transparent;
}
</style>
+86 -16
View File
@@ -1,7 +1,10 @@
<script lang="ts">
import TerminalSlot from "$lib/plugins/TerminalSlot.svelte";
import PluginTools from "$lib/plugins/PluginTools.svelte";
import { onMount, tick } from "svelte";
import { selectedEditorText } from "$lib/editor/selection";
import { terminalShortcut } from "$lib/terminal/model";
import { pluginHost } from "$lib/plugins/registry";
import type { Contributions } from "$lib/plugins/contracts";
import { isTauri } from "@tauri-apps/api/core";
import { getCurrentWindow } from "@tauri-apps/api/window";
import { confirm } from "@tauri-apps/plugin-dialog";
@@ -13,6 +16,8 @@
import TextDialog from "./TextDialog.svelte";
import QuickOpen from "./QuickOpen.svelte";
import WorkspacePicker from "./WorkspacePicker.svelte";
import SettingsDialog from "./SettingsDialog.svelte";
import { DEFAULT_SETTINGS, SETTINGS_KEY, parseSettings, saveSettings, type AppSettings } from "$lib/workspace/settings";
import FileTree from "./FileTree.svelte";
import EditorPane from "./EditorPane.svelte";
import TabBar from "./TabBar.svelte";
@@ -21,7 +26,7 @@
import WindowControls from "$lib/ui/WindowControls.svelte";
import SearchPane from "./SearchPane.svelte";
import BookmarksPane from "./BookmarksPane.svelte";
import TerminalDock from "./TerminalDock.svelte";
import { buildOutline } from "$lib/workspace/outline";
import {
onWorkspaceEvent,
@@ -46,6 +51,9 @@
let workspace = $state<WorkspaceInfo | null>(null);
let workspacePicker: WorkspacePicker;
let preferences = $state<"settings" | "help" | null>(null);
let settings = $state<AppSettings>({ ...DEFAULT_SETTINGS });
let settingsReady = $state(false);
let workspaceAnchor: HTMLDivElement | undefined = $state();
const desktop = isTauri();
let tabs = $state<OpenBuffer[]>([]);
@@ -67,7 +75,16 @@
let quickOpen = $state(false);
let terminalStarted = $state(false);
let terminalMaximized = $state(false);
let terminalDock: TerminalDock | undefined = $state();
let terminalDock: TerminalSlot | undefined = $state();
const terminalContribution = $derived.by(() => { void $pluginHost; return pluginHost.get("terminal"); });
const terminalEnabled = $derived(!!terminalContribution);
$effect(() => {
if (!terminalEnabled) {
terminalOpen = false; terminalStarted = false; terminalMaximized = false;
}
});
let saving = $state(false);
let switching = false;
let documents: Documents | null = null;
@@ -110,18 +127,20 @@
}
function toggleTerminal() {
if (!terminalEnabled) return;
terminalOpen = !terminalOpen;
if (terminalOpen) terminalStarted = true;
if (terminalOpen) { terminalStarted = true; }
if (terminalOpen && bottomHeight < 220) bottomHeight = 260;
}
async function terminalAction(action: Exclude<ReturnType<typeof terminalShortcut>, null | "toggle">) {
async function terminalAction(action: Exclude<ReturnType<Contributions["terminal"]["shortcut"]>, null | "toggle">) {
if (!terminalEnabled) return;
if (!workspace) { error = "Open a workspace to start a terminal."; return; }
const started = terminalStarted;
terminalStarted = true; terminalOpen = true;
if (bottomHeight < 220) bottomHeight = 260;
await tick();
if (action !== "new" || started) await terminalDock?.command(action);
if (terminalEnabled && (action !== "new" || started)) await terminalDock?.command(action);
}
async function terminalFile(): Promise<string | null> {
@@ -269,6 +288,14 @@
} catch (err) { if (documents === current) error = String(err); }
}
async function openCreatedFile(entry: TreeEntry) {
const current = documents;
await openFile(entry);
if (documents !== current || current?.active?.relPath !== entry.rel_path || !isMarkdownPath(entry.rel_path)) return;
reading = false;
editorPane?.focusTitle(current.active.id);
}
function readFileDataUrl(file: File): Promise<string> {
return new Promise((resolve, reject) => {
const reader = new FileReader();
@@ -384,7 +411,7 @@
try {
await workspaceCreate(name.replaceAll("\\", "/"), "file");
refreshToken += 1;
await openFile({
await openCreatedFile({
name: name.split("/").pop() ?? name,
rel_path: name.replaceAll("\\", "/"),
kind: "file",
@@ -394,9 +421,19 @@
}
}
function onPreferencesKeydown(event: KeyboardEvent) {
if (event.target instanceof Element && event.target.closest("dialog, [role=dialog], [role=menu]")) return;
if ((event.ctrlKey || event.metaKey) && !event.shiftKey && !event.altKey && event.key === ",") {
event.preventDefault(); event.stopPropagation(); preferences = "settings";
}
if (event.key === "F1" && !event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey) {
event.preventDefault(); event.stopPropagation(); preferences = "help";
}
}
function onKeydown(event: KeyboardEvent) {
if (event.target instanceof Element && event.target.closest("dialog, [role=dialog], [role=menu]")) return;
const action = terminalShortcut(event);
const action = pluginHost.get("terminal")?.shortcut(event);
const terminalTarget = event.target instanceof Element && !!event.target.closest(".dock");
if (action && (["toggle", "new", "split", "window"].includes(action) || terminalTarget)) {
event.preventDefault();
@@ -431,7 +468,7 @@
event.preventDefault();
toggleChrome();
}
if ((event.ctrlKey || event.metaKey) && event.key === "`") {
if (terminalEnabled && (event.ctrlKey || event.metaKey) && event.key === "`") {
event.preventDefault();
toggleTerminal();
}
@@ -540,14 +577,38 @@
}
}
function updateSettings(next: AppSettings) {
saveSettings(localStorage, next);
settings = { ...next };
}
onMount(() => {
try { settings = parseSettings(localStorage.getItem(SETTINGS_KEY)); }
catch { error = "Could not read your settings. Default settings apply until you save new settings."; }
settingsReady = true;
const syncSettings = (event: StorageEvent) => {
if (event.storageArea === localStorage && (event.key === SETTINGS_KEY || event.key === null)) settings = parseSettings(event.newValue);
};
window.addEventListener("storage", syncSettings);
window.addEventListener("keydown", onPreferencesKeydown, true);
return () => {
window.removeEventListener("storage", syncSettings);
window.removeEventListener("keydown", onPreferencesKeydown, true);
};
});
$effect(() => {
if (!desktop || !settingsReady || !settings.autosaveEnabled) return;
const timer = setInterval(() => { void autosave(); }, settings.autosaveSeconds * 1000);
return () => clearInterval(timer);
});
onMount(() => {
if (!isTauri()) { status = "Desktop features require pnpm tauri dev"; return; }
void restoreLast();
let disposed = false;
const unlisteners: (() => void)[] = [];
let refreshTimer: ReturnType<typeof setTimeout>;
// A fixed interval also saves during continuous typing; clean files never write.
const autosaveTimer = setInterval(() => { void autosave(); }, 5_000);
const register = (off: () => void) => { if (disposed) off(); else unlisteners.push(off); };
void onWorkspaceEvent((event) => {
if (event.root !== workspace?.root || event.kind === "access") return;
@@ -576,7 +637,6 @@
documents?.dispose();
clearTimeout(refreshTimer);
unlisteners.forEach(off => off());
clearInterval(autosaveTimer);
window.removeEventListener("focus", focus);
};
});
@@ -586,6 +646,7 @@
<svelte:window onkeydown={onKeydown} onbeforeunload={(event) => { if (hasDirty) { event.preventDefault(); event.returnValue = ""; } }} />
<TextDialog />
<WorkspacePicker bind:this={workspacePicker} currentRoot={workspace?.root} anchor={workspaceAnchor} onOpen={openPath} />
{#if preferences}<SettingsDialog {settings} help={preferences === "help"} onSave={updateSettings} onClose={() => preferences = null} />{/if}
{#if quickOpen && workspace}<QuickOpen onOpen={(entry) => void openFile(entry)} onClose={() => quickOpen = false} />{/if}
<div
@@ -632,8 +693,9 @@
{#if desktop}<div class="window-drag-space" data-tauri-drag-region></div>{/if}
</div>
<div class="header-right" data-tauri-drag-region>
<PluginTools />
<IconButton icon="save" label="Save" disabled={!dirty || saving} onclick={() => void save()} />
<IconButton icon="terminal" label="Terminal" active={terminalOpen} onclick={toggleTerminal} />
{#if terminalEnabled}<IconButton icon="terminal" label="Terminal" active={terminalOpen} onclick={toggleTerminal} />{/if}
<IconButton
icon="panel-right"
label={rightOpen ? "Hide outline" : "Show outline"}
@@ -659,7 +721,7 @@
{refreshToken}
keysActive={leftView === "files"}
onCreated={(entry) => {
void openFile(entry);
void openCreatedFile(entry);
}}
onStatus={(message) => {
status = message;
@@ -682,6 +744,10 @@
<IconButton icon="folder-open" label="Open folder" onclick={chooseWorkspace} />
<span class="ws">{workspace ? workspace.name : "No workspace"}</span>
</div>
<div class="footer-actions">
<IconButton icon="help" label="Help and about (F1)" onclick={() => preferences = "help"} />
<IconButton icon="settings" label="Settings (Ctrl+,)" onclick={() => preferences = "settings"} />
</div>
</div>
</aside>
@@ -727,7 +793,7 @@
/>
</div>
</main>
{#if terminalStarted}
{#if terminalContribution && terminalStarted}
<div
class="gutter gutter-h" class:terminal-hidden={!terminalOpen}
role="separator"
@@ -736,7 +802,7 @@
<section class="bottom" class:terminal-hidden={!terminalOpen}>
{#if workspace}
{#key workspace.root}
<TerminalDock bind:this={terminalDock} cwd={workspace.root} visible={terminalOpen} onClose={toggleTerminal}
<TerminalSlot contribution={terminalContribution} bind:this={terminalDock} cwd={workspace.root} visible={terminalOpen} onClose={toggleTerminal}
maximized={terminalMaximized} onMaximize={() => terminalMaximized = !terminalMaximized}
activeFile={buffer?.kind === "text" && !reading} onRunFile={terminalFile}
getSelection={() => selectedEditorText(buffer?.id)} onConfigureTasks={configureTasks} />
@@ -973,12 +1039,16 @@
}
.footer-start {
flex: 1;
display: flex;
align-items: center;
gap: 2px;
min-width: 0;
}
.footer-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.footer-actions :global(.icon-btn) { width: 32px; height: 32px; flex-basis: 32px; }
.placeholder {
margin: 12px;
color: var(--rs-text-dim);