Show one view control and name the file once
Phase 5-3. - One radio group shows Write, Source, and Read at all times, with an icon and a name. Narrow panes show only the icons. The arrow keys move the choice, and the group has one Tab stop. The current choice gets the selection fill and an accent bar. Hover gets only a fill. - A Split toggle shows Read beside Write or Source. Each document pane keeps a split flag beside its reading flag. Read ends Split. - Ctrl+Shift+E switches between Read and the editor. Ctrl+E still switches between Write and Source. - "IDE" becomes "Source" in the Chrome type, the tab menu (a View submenu), the status bar, the catalog, the tests, and the docs. - Settings, General, File name title hides the title in Write and Read. It is on by default. - The breadcrumb shows only the folder of the file. The status bar shows the view, not the path. - ModeSwitcher.svelte and its hover test are gone. The new test layout/viewModes covers the control. - The command palette from 5-2 gets its row in docs/menu-surfaces.json. - The user guide Format table is whole again. The 5-2 edit had put the Paragraph and Insert rows under the shortcut table. - 8 new catalog rows and 10 removed rows, in French, Japanese, and Simplified Chinese. - Docs: UI-049, the user guide, ui-design.md, document-tools.md, development.md, and the README feature list. Tests: the new layout/viewModes, new cases in documentPanes.spec.ts and settings.spec.ts, and the chooseView harness helper. 21 smoke tests use the new control. Tests that read the full path from the breadcrumb now read its tooltip.
This commit is contained in:
@@ -9,7 +9,8 @@
|
||||
import type { MenuLink } from "$lib/editor/linkMenu";
|
||||
import { WorkspaceSession } from "$lib/workspace/session.svelte";
|
||||
import { retainEditorStates } from "$lib/editor/editorStates";
|
||||
import { initialDocumentPanes, syncDocumentPanes, splitDocumentPane, closeDocumentPane, selectPane, readDocumentPane } from "$lib/workspace/documentPanes";
|
||||
import { initialDocumentPanes, syncDocumentPanes, splitDocumentPane, closeDocumentPane, selectPane, readDocumentPane, splitDocumentView } from "$lib/workspace/documentPanes";
|
||||
import type { ViewMode } from "./ViewModes.svelte";
|
||||
import { selectedEditorText } from "$lib/editor/selection";
|
||||
import { pluginHost } from "$lib/plugins/registry";
|
||||
import type { Contributions } from "$lib/plugins/contracts";
|
||||
@@ -146,7 +147,8 @@
|
||||
$effect(() => { if ($pluginSidebar && !transferredWindow) leftOpen = true; });
|
||||
let terminalOpen = $state(false);
|
||||
let documentPanes = $state(initialDocumentPanes());
|
||||
const reading = $derived(documentPanes.panes.find(pane => pane.id === documentPanes.active)?.reading ?? false);
|
||||
const activeDocumentPane = $derived(documentPanes.panes.find(pane => pane.id === documentPanes.active));
|
||||
const reading = $derived(activeDocumentPane?.reading ?? false);
|
||||
let quickOpen = $state(false);
|
||||
let palette = $state(false);
|
||||
/** The commands of the palette: the app commands that apply here, then the plugin commands. */
|
||||
@@ -362,7 +364,10 @@
|
||||
if (order.length !== tabOrder.length || order.some((id, index) => id !== tabOrder[index])) tabOrder = order;
|
||||
});
|
||||
const dirty = $derived(buffer !== null && buffer.contents !== buffer.saved);
|
||||
const isIde = $derived(view === "Ide");
|
||||
const isSource = $derived(view === "Source");
|
||||
const readable = $derived(buffer?.kind === "text" && isMarkdownPath(buffer.relPath));
|
||||
// The status bar names the view of the active pane. Split shows the editor view.
|
||||
const viewMode: ViewMode = $derived(reading && readable ? "read" : isSource ? "source" : "write");
|
||||
const outlineItems = $derived(
|
||||
buffer && buffer.kind === "text" ? buildOutline(buffer.relPath, buffer.contents) : [],
|
||||
);
|
||||
@@ -372,12 +377,26 @@
|
||||
}
|
||||
|
||||
function toggleChrome() {
|
||||
const next = view === "Writing" ? "Ide" : "Writing";
|
||||
const next = view === "Writing" ? "Source" : "Writing";
|
||||
setReading(false);
|
||||
applyChrome(next);
|
||||
documents?.setChrome(next);
|
||||
}
|
||||
|
||||
/** Show Write, Source, or Read in a pane. Write and Source keep a Split view. */
|
||||
function setDocumentView(paneId: string, next: ViewMode) {
|
||||
focusDocumentPane(paneId);
|
||||
if (next === "read") { setReading(true, paneId); return; }
|
||||
setReading(false, paneId);
|
||||
const chrome = next === "source" ? "Source" : "Writing";
|
||||
if (chrome !== view) { applyChrome(chrome); documents?.setChrome(chrome); }
|
||||
}
|
||||
|
||||
function setSplitView(paneId: string, split: boolean) {
|
||||
focusDocumentPane(paneId);
|
||||
documentPanes = splitDocumentView(documentPanes, paneId, split);
|
||||
}
|
||||
|
||||
function toggleTerminal() {
|
||||
if (!terminalEnabled) return;
|
||||
terminalOpen = !terminalOpen;
|
||||
@@ -510,7 +529,7 @@
|
||||
focusLine = null;
|
||||
documents?.select(relPath);
|
||||
focusDocumentPane(documentPanes.active, true);
|
||||
status = documents?.active?.kind === "empty" ? $t("New tab") : relPath;
|
||||
status = documents?.active?.kind === "empty" ? $t("New tab") : "";
|
||||
}
|
||||
|
||||
function selectWorkingTab(path: string) {
|
||||
@@ -660,8 +679,13 @@
|
||||
if (tab.kind === "text" && isMarkdownPath(tab.relPath)) {
|
||||
items.push(
|
||||
{ label: $t("Save as template"), icon: "copy", run: () => { void saveTemplate({ name: tab.name, rel_path: tab.relPath, kind: "file" }); } },
|
||||
{ label: reading ? $t("Editing view") : $t("Reading view"), icon: "book", run: () => activeEditor()?.toggleReadingView() },
|
||||
{ label: isIde ? $t("Writing mode") : $t("Source mode"), icon: "code", run: toggleChrome },
|
||||
{ label: $t("View"), icon: "book", children: [
|
||||
{ label: $t("Write"), icon: "paragraph", radio: true, checked: viewMode === "write", run: () => setDocumentView(documentPanes.active, "write") },
|
||||
{ label: $t("Source"), icon: "code", radio: true, checked: viewMode === "source", run: () => setDocumentView(documentPanes.active, "source") },
|
||||
{ label: $t("Read"), icon: "book", radio: true, checked: viewMode === "read", run: () => setDocumentView(documentPanes.active, "read") },
|
||||
{ separator: true },
|
||||
{ label: $t("Split"), icon: "split-right", checked: activeDocumentPane?.split === true && !reading, run: () => setSplitView(documentPanes.active, !(activeDocumentPane?.split && !reading)) },
|
||||
] },
|
||||
);
|
||||
}
|
||||
items.push({ separator: true },
|
||||
@@ -684,12 +708,12 @@
|
||||
try {
|
||||
const open = current.buffers.find(tab => tab.relPath === entry.rel_path);
|
||||
if (!line && !(open && open.contents !== open.saved) && await openPluginDocument(entry.rel_path, () => documents === current && !switching)) {
|
||||
status = entry.rel_path; error = null; return;
|
||||
status = ""; error = null; return;
|
||||
}
|
||||
await current.open(entry, target);
|
||||
if (documents !== current) return;
|
||||
pluginEditorActive.set(false);
|
||||
status = entry.rel_path;
|
||||
status = "";
|
||||
error = null;
|
||||
focusLine = null;
|
||||
if (line) {
|
||||
@@ -882,6 +906,7 @@
|
||||
case "open-workspace": void chooseWorkspace(); return true;
|
||||
case "new-file": void newFile(); return true;
|
||||
case "toggle-layout": if (!editorPluginVisible) toggleChrome(); return true;
|
||||
case "toggle-reading": if (!editorPluginVisible && readable) setReading(!reading); return true;
|
||||
case "toggle-terminal": if (!terminalEnabled) return false; toggleTerminal(); return true;
|
||||
case "close-tab":
|
||||
if (editorPluginVisible) { if (activeTabPath) void closeTab(activeTabPath); }
|
||||
@@ -1281,8 +1306,8 @@
|
||||
defaultBrowser: target => openUrl(target),
|
||||
workspaceItems: link => workspaceLinkItems(link, pane.buffer?.relPath ?? "", pane.id),
|
||||
})}
|
||||
onToggleReading={(pane) => setReading(!pane.reading, pane.id)}
|
||||
onToggleChrome={(pane) => { focusDocumentPane(pane.id); toggleChrome(); }}
|
||||
onView={(pane, next) => setDocumentView(pane.id, next)}
|
||||
onSplitView={(pane, next) => setSplitView(pane.id, next)}
|
||||
onOpenLink={(pane, kind, target) => void openLink(kind, target, pane.buffer?.relPath ?? "", pane.id)}
|
||||
/>
|
||||
{#if terminalContribution && terminalStarted}
|
||||
@@ -1329,7 +1354,7 @@
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<StatusBar message={error ?? status} watchMode={workspace?.watch_mode ?? null} source={isIde} />
|
||||
<StatusBar message={error ?? status} watchMode={workspace?.watch_mode ?? null} view={buffer?.kind === "text" ? viewMode : null} />
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
||||
Reference in New Issue
Block a user