From c8a91e5b0f9f8d47bafc63fcc1b984f3df5be03c Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Tue, 17 Nov 2026 23:01:12 +0800 Subject: [PATCH] feat(appearance): Presentation Assistant (#4026) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While on, each action the user runs shows its name and shortcut in a popup, for screencasts and demos. Toggled from View › Appearance › Presentation Assistant; Settings › Appearance › Presentation Assistant sets the popup size, duration, position and whether to also show the other platform's shortcut (macOS ⇄ Windows/Linux). Hidden actions are not shown. Closes #3949 --- crates/ide-core/src/settings.rs | 30 +++++ src-tauri/src/menu.rs | 1 + src/bindings.ts | 17 +++ .../__tests__/presentationAssistant.test.tsx | 111 ++++++++++++++++++ src/features/settings/appearanceRuntime.ts | 20 ++++ src/features/settings/index.ts | 10 +- src/features/settings/model/behaviorSchema.ts | 42 +++++++ src/features/settings/pages/behavior.tsx | 62 ++++++++++ .../PresentationAssistant.module.css | 107 +++++++++++++++++ .../presentation/PresentationAssistant.tsx | 65 ++++++++++ .../settings/presentation/presentation.ts | 43 +++++++ src/platform/locales/en.json | 1 + src/platform/locales/text/en.json | 12 ++ src/platform/locales/text/zh.json | 12 ++ src/platform/locales/zh.json | 1 + 15 files changed, 533 insertions(+), 1 deletion(-) create mode 100644 src/features/settings/__tests__/presentationAssistant.test.tsx create mode 100644 src/features/settings/presentation/PresentationAssistant.module.css create mode 100644 src/features/settings/presentation/PresentationAssistant.tsx create mode 100644 src/features/settings/presentation/presentation.ts diff --git a/crates/ide-core/src/settings.rs b/crates/ide-core/src/settings.rs index aefb17c7a..3d0609e7c 100644 --- a/crates/ide-core/src/settings.rs +++ b/crates/ide-core/src/settings.rs @@ -783,6 +783,35 @@ pub struct AppearanceSettings { pub main_toolbar: Option, /// Appearance › Background Image: an image shown through the IDE window. pub background_image: BackgroundImageSettings, + /// Appearance › Presentation Assistant: the name and shortcut of each action run. + pub presentation_assistant: PresentationAssistantSettings, +} + +/// Appearance › Presentation Assistant: shows the name and shortcut of each action the user runs. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] +#[serde(default, rename_all = "camelCase")] +pub struct PresentationAssistantSettings { + pub enabled: bool, + /// `small` | `medium` | `large`. + pub size: String, + /// How long each popup stays, in seconds. + pub duration_seconds: u32, + /// `top-left`, `top`, `top-right`, `bottom-left`, `bottom` or `bottom-right` of the window. + pub position: String, + /// Also show the shortcut of the other platform's keymap (macOS ⇄ Windows/Linux). + pub alternate_keymap: bool, +} + +impl Default for PresentationAssistantSettings { + fn default() -> Self { + Self { + enabled: false, + size: "medium".into(), + duration_seconds: 4, + position: "bottom".into(), + alternate_keymap: false, + } + } } /// Appearance › Background Image. An empty `path` shows no image. @@ -875,6 +904,7 @@ impl Default for AppearanceSettings { status_bar_widgets: BTreeMap::new(), main_toolbar: None, background_image: BackgroundImageSettings::default(), + presentation_assistant: PresentationAssistantSettings::default(), } } } diff --git a/src-tauri/src/menu.rs b/src-tauri/src/menu.rs index 642764147..69beed3a4 100644 --- a/src-tauri/src/menu.rs +++ b/src-tauri/src/menu.rs @@ -396,6 +396,7 @@ pub fn spec(os: Os) -> Vec { act("editor.toggleZen", "Enter Distraction Free Mode"), act("window.toggleFullScreen", "Toggle Full Screen"), toggle("view.toggleCompactMode", "Compact Mode"), + toggle("view.togglePresentationAssistant", "Presentation Assistant"), SEP, act("view.zoomIn", "Zoom In IDE"), act("view.zoomOut", "Zoom Out IDE"), diff --git a/src/bindings.ts b/src/bindings.ts index 5ec71ca3a..46168a2fa 100644 --- a/src/bindings.ts +++ b/src/bindings.ts @@ -2812,6 +2812,8 @@ export type AppearanceSettings_Deserialize = { mainToolbar?: MainToolbarSettings | null, /** Appearance › Background Image: an image shown through the IDE window. */ backgroundImage?: BackgroundImageSettings, + /** Appearance › Presentation Assistant: the name and shortcut of each action run. */ + presentationAssistant?: PresentationAssistantSettings, }; export type AppearanceSettings_Serialize = { @@ -2881,6 +2883,8 @@ export type AppearanceSettings_Serialize = { mainToolbar: MainToolbarSettings | null, /** Appearance › Background Image: an image shown through the IDE window. */ backgroundImage: BackgroundImageSettings, + /** Appearance › Presentation Assistant: the name and shortcut of each action run. */ + presentationAssistant: PresentationAssistantSettings, }; export type ApplyOutcome = { @@ -9213,6 +9217,19 @@ export type PreparedRequest = { body: string | null, }; +/** Appearance › Presentation Assistant: shows the name and shortcut of each action the user runs. */ +export type PresentationAssistantSettings = { + enabled?: boolean, + /** `small` | `medium` | `large`. */ + size?: string, + /** How long each popup stays, in seconds. */ + durationSeconds?: number, + /** `top-left`, `top`, `top-right`, `bottom-left`, `bottom` or `bottom-right` of the window. */ + position?: string, + /** Also show the shortcut of the other platform's keymap (macOS ⇄ Windows/Linux). */ + alternateKeymap?: boolean, +}; + export type ProblemSeverity = "info" | "warning" | "error" | /** The refactoring can't run at all; there is no edit. */ "fatal"; diff --git a/src/features/settings/__tests__/presentationAssistant.test.tsx b/src/features/settings/__tests__/presentationAssistant.test.tsx new file mode 100644 index 000000000..8a08acef8 --- /dev/null +++ b/src/features/settings/__tests__/presentationAssistant.test.tsx @@ -0,0 +1,111 @@ +import { act, cleanup, render, screen } from "@testing-library/react"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import type { ActionContext } from "@/platform/actions"; +import type { Settings } from "@/platform/ipc"; + +const settingsSet = vi.fn(); + +vi.mock("@/platform/ipc", async (importOriginal) => { + const real = await importOriginal(); + return { + ...real, + isTauri: () => true, + commands: { ...real.commands, settingsSet: (...a: unknown[]) => settingsSet(...a) }, + }; +}); + +import { executeAction, registerActions } from "@/platform/actions"; +import { useKeymap } from "@/platform/keymap"; +import { usePlatform } from "@/platform/platformInfo"; +import { useProject } from "@/platform/project"; +import { presentationAssistantAction } from "../appearanceRuntime"; +import { validateAppearanceExtras } from "../model/behaviorSchema"; +import { PresentationAssistant } from "../presentation/PresentationAssistant"; +import { alternatePreset, presentAction } from "../presentation/presentation"; + +let assistant: Record; +const disposers: Array<() => void> = []; + +function useSettings(patch: Record) { + assistant = { ...assistant, ...patch }; + useProject.setState({ settings: { appearance: { presentationAssistant: { ...assistant } } } as unknown as Settings }); +} + +beforeEach(() => { + assistant = {}; + useSettings({}); + usePlatform.setState({ os: "macos" }); + useKeymap.setState({ preset: "intellij-macos", overrides: {}, extensions: {} }); + disposers.push( + registerActions([ + { id: "file.save", title: "Save All", category: "File", run: () => {} }, + { id: "test.unbound", title: "Unbound Action", run: () => {} }, + { id: "test.internal", title: "Internal Step", hidden: true, run: () => {} }, + ]), + ); + settingsSet.mockReset().mockImplementation(async (_scope: string, key: string, json: string) => { + useSettings({ [key.replace("appearance.presentationAssistant.", "")]: JSON.parse(json) }); + return { status: "ok", data: useProject.getState().settings }; + }); +}); + +afterEach(() => { + cleanup(); + vi.useRealTimers(); + while (disposers.length) disposers.pop()!(); + useProject.setState({ settings: null }); +}); + +describe("Presentation Assistant", () => { + it("is off by default and keeps its options in range", () => { + expect(validateAppearanceExtras({}).presentationAssistant).toEqual({ + enabled: false, + size: "medium", + durationSeconds: 4, + position: "bottom", + alternateKeymap: false, + }); + expect( + validateAppearanceExtras({ presentationAssistant: { size: "huge", durationSeconds: 0, position: "middle" } }) + .presentationAssistant, + ).toMatchObject({ size: "medium", durationSeconds: 1, position: "bottom" }); + }); + + it("names the action with its shortcut, and the other platform's on request", () => { + expect(presentAction("file.save", false)).toEqual({ title: "Save All", shortcut: "⌘S" }); + expect(presentAction("file.save", true)).toEqual({ + title: "Save All", + shortcut: "⌘S", + alternate: { keymap: "Windows/Linux", shortcut: "Ctrl+S" }, + }); + expect(presentAction("file.save", true, false)?.alternate).toEqual({ keymap: "macOS", shortcut: "⌘S" }); + expect(presentAction("test.unbound", true)).toEqual({ title: "Unbound Action", shortcut: undefined }); + expect(presentAction("test.internal", false)).toBeNull(); + expect(alternatePreset("vscode-macos", true)).toBe("vscode-windows"); + expect(alternatePreset("my-custom-keymap", false)).toBe("intellij-macos"); + }); + + it("shows each action run while enabled and hides it after the duration", async () => { + vi.useFakeTimers(); + render(); + await act(async () => void (await executeAction("file.save"))); + expect(screen.queryByTestId("presentation-assistant")).toBeNull(); + + act(() => useSettings({ enabled: true, durationSeconds: 2 })); + await act(async () => void (await executeAction("file.save"))); + expect(screen.getByTestId("presentation-assistant").textContent).toBe("Save All⌘S"); + + act(() => vi.advanceTimersByTime(1500)); + expect(screen.getByTestId("presentation-assistant")).toBeTruthy(); + act(() => vi.advanceTimersByTime(600)); + expect(screen.queryByTestId("presentation-assistant")).toBeNull(); + }); + + it("is toggled from View › Appearance", async () => { + const action = presentationAssistantAction(); + expect(action.toggled?.()).toBe(false); + await action.run({ ctx: {} } as ActionContext); + expect(settingsSet).toHaveBeenCalledWith("global", "appearance.presentationAssistant.enabled", "true"); + expect(action.toggled?.()).toBe(true); + }); +}); diff --git a/src/features/settings/appearanceRuntime.ts b/src/features/settings/appearanceRuntime.ts index 8a756045b..927ebd4f7 100644 --- a/src/features/settings/appearanceRuntime.ts +++ b/src/features/settings/appearanceRuntime.ts @@ -208,6 +208,26 @@ export function appearanceToggleActions(): Action[] { ]; } +/** View › Appearance › Presentation Assistant. */ +export function presentationAssistantAction(): Action { + const enabled = () => validateSettings(useProject.getState().settings).appearance.presentationAssistant.enabled; + return { + id: "view.togglePresentationAssistant", + title: "Presentation Assistant", + category: "View", + keywords: ["appearance", "show shortcuts", "action names", "screencast", "demo", "key promoter"], + toggled: enabled, + run: async () => { + if (!isTauri()) return; + useProject.setState({ + settings: await call( + commands.settingsSet("global", "appearance.presentationAssistant.enabled", JSON.stringify(!enabled())), + ), + }); + }, + }; +} + // --------------------------------------------------------------------------- // View › Appearance › Navigation Bar: a radio choice (Top / Status Bar / hidden) diff --git a/src/features/settings/index.ts b/src/features/settings/index.ts index 92dbc0e4a..42f5a1901 100644 --- a/src/features/settings/index.ts +++ b/src/features/settings/index.ts @@ -38,7 +38,13 @@ import { settingsTitle, useSettingsDialog, } from "./model/staging"; -import { appearanceToggleActions, navigationBarActions, zoomActions } from "./appearanceRuntime"; +import { + appearanceToggleActions, + navigationBarActions, + presentationAssistantAction, + zoomActions, +} from "./appearanceRuntime"; +import { PresentationAssistant } from "./presentation/PresentationAssistant"; import { activateFileTypes } from "./fileTypesRuntime"; import { trackRuntimeSettings } from "./runtime"; import { installActionProxies, installSettingsHost } from "./window/bridge"; @@ -129,6 +135,8 @@ export function activate(): () => void { registerOverlay({ id: "settings.projectStructure", component: LazyProjectStructureDialog }), registerActions(zoomActions()), registerActions(appearanceToggleActions()), + registerActions([presentationAssistantAction()]), + registerOverlay({ id: "settings.presentationAssistant", component: PresentationAssistant }), registerActions(navigationBarActions()), registerActions(settingsActions((page, newProjects) => void showSettings(page, newProjects))), registerActions([ diff --git a/src/features/settings/model/behaviorSchema.ts b/src/features/settings/model/behaviorSchema.ts index 73fb5b3bf..e12ee2701 100644 --- a/src/features/settings/model/behaviorSchema.ts +++ b/src/features/settings/model/behaviorSchema.ts @@ -35,6 +35,27 @@ export interface BackgroundImageValid { fill: BackgroundImageFill; anchor: BackgroundImageAnchor; } +export type PresentationAssistantSize = "small" | "medium" | "large"; +export const PRESENTATION_ASSISTANT_POSITIONS = [ + "top-left", + "top", + "top-right", + "bottom-left", + "bottom", + "bottom-right", +] as const; +export type PresentationAssistantPosition = (typeof PRESENTATION_ASSISTANT_POSITIONS)[number]; +export const PRESENTATION_ASSISTANT_DURATION = { min: 1, max: 60 } as const; + +/** Appearance › Presentation Assistant: the name and shortcut of each action the user runs. */ +export interface PresentationAssistantValid { + enabled: boolean; + size: PresentationAssistantSize; + durationSeconds: number; + position: PresentationAssistantPosition; + /** Also show the other platform's shortcut (macOS ⇄ Windows/Linux). */ + alternateKeymap: boolean; +} /** Themes selectable as "preferred" when syncing with the OS. */ export type ConcreteTheme = ThemeChoiceId; @@ -77,6 +98,7 @@ export interface AppearanceExtras { * the editor, in the status bar, or not at all. */ navigationBar: NavigationBarPosition; backgroundImage: BackgroundImageValid; + presentationAssistant: PresentationAssistantValid; } export interface DateFormatValid { @@ -156,6 +178,13 @@ export const DEFAULT_APPEARANCE_EXTRAS: AppearanceExtras = { showStatusBar: true, navigationBar: "statusBar", backgroundImage: { path: "", opacity: 15, fill: "scale", anchor: "center" }, + presentationAssistant: { + enabled: false, + size: "medium", + durationSeconds: 4, + position: "bottom", + alternateKeymap: false, + }, }; const NAV_BAR_POSITIONS: readonly NavigationBarPosition[] = ["top", "statusBar", "hidden"]; @@ -238,6 +267,19 @@ export function validateAppearanceExtras(raw: unknown): AppearanceExtras { return oneOf(a.navigationBar, NAV_BAR_POSITIONS, d.navigationBar); })(), backgroundImage: validateBackgroundImage(a.backgroundImage), + presentationAssistant: validatePresentationAssistant(a.presentationAssistant), + }; +} + +function validatePresentationAssistant(raw: unknown): PresentationAssistantValid { + const p = obj(raw); + const d = DEFAULT_APPEARANCE_EXTRAS.presentationAssistant; + return { + enabled: bool(p.enabled, d.enabled), + size: oneOf(p.size, ["small", "medium", "large"], d.size), + durationSeconds: int(p.durationSeconds, d.durationSeconds, PRESENTATION_ASSISTANT_DURATION), + position: oneOf(p.position, PRESENTATION_ASSISTANT_POSITIONS, d.position), + alternateKeymap: bool(p.alternateKeymap, d.alternateKeymap), }; } diff --git a/src/features/settings/pages/behavior.tsx b/src/features/settings/pages/behavior.tsx index 5edae5155..400699549 100644 --- a/src/features/settings/pages/behavior.tsx +++ b/src/features/settings/pages/behavior.tsx @@ -32,6 +32,9 @@ import { type NotificationGroupValid, type NavigationBarPosition, type OpenProjectIn, + PRESENTATION_ASSISTANT_DURATION, + type PresentationAssistantPosition, + type PresentationAssistantSize, } from "../model/behaviorSchema"; import { ACCENT_PRESETS, LIMITS, type ThemeId } from "../model/schema"; import type { PageSpec } from "./spec"; @@ -393,6 +396,21 @@ const AA_OPTIONS: SelectOption[] = [ { value: "none", label: "No antialiasing" }, ]; +const PRESENTATION_SIZE_OPTIONS: SelectOption[] = [ + { value: "small", label: "Small" }, + { value: "medium", label: "Medium" }, + { value: "large", label: "Large" }, +]; + +const PRESENTATION_POSITION_OPTIONS: SelectOption[] = [ + { value: "top-left", label: "Top left" }, + { value: "top", label: "Top center" }, + { value: "top-right", label: "Top right" }, + { value: "bottom-left", label: "Bottom left" }, + { value: "bottom", label: "Bottom center" }, + { value: "bottom-right", label: "Bottom right" }, +]; + const NAV_BAR_OPTIONS: SelectOption[] = [ { value: "top", label: "Top" }, { value: "statusBar", label: "Status Bar" }, @@ -966,6 +984,50 @@ export const BEHAVIOR_PAGES: PageSpec[] = [ }, ], }, + { + id: "appearance.presentationAssistant", + title: "Presentation Assistant", + order: 0, + keywords: ["action names", "shortcuts", "screencast", "demo", "presentation"], + sections: [ + { + options: [ + { + kind: "toggle", + key: "appearance.presentationAssistant.enabled", + label: "Show action names and shortcuts", + hint: "Each action you run shows its name and shortcut in a popup, for screencasts and demos.", + }, + { + kind: "select", + key: "appearance.presentationAssistant.size", + label: "Popup size", + options: PRESENTATION_SIZE_OPTIONS, + }, + { + kind: "number", + key: "appearance.presentationAssistant.durationSeconds", + label: "Duration", + ...PRESENTATION_ASSISTANT_DURATION, + integer: true, + unit: "seconds", + }, + { + kind: "select", + key: "appearance.presentationAssistant.position", + label: "Popup position", + options: PRESENTATION_POSITION_OPTIONS, + }, + { + kind: "toggle", + key: "appearance.presentationAssistant.alternateKeymap", + label: "Also show the other platform's shortcut", + hint: "macOS shortcuts on Windows and Linux, Windows/Linux shortcuts on macOS.", + }, + ], + }, + ], + }, { id: "general", title: "System Settings", diff --git a/src/features/settings/presentation/PresentationAssistant.module.css b/src/features/settings/presentation/PresentationAssistant.module.css new file mode 100644 index 000000000..a8490b3c9 --- /dev/null +++ b/src/features/settings/presentation/PresentationAssistant.module.css @@ -0,0 +1,107 @@ +.popup { + position: fixed; + z-index: var(--z-toast); + display: flex; + align-items: baseline; + gap: var(--space-3); + max-width: calc(100vw - 32px); + padding: var(--space-3) var(--space-4); + border: 1px solid var(--border-popup); + border-radius: var(--radius-popup-large); + background: var(--bg-popup); + box-shadow: var(--shadow-popup); + color: var(--fg-strong); + pointer-events: none; + white-space: nowrap; + animation: fade-in 120ms ease-out; +} + +.leaving { + opacity: 0; + transition: opacity 300ms ease-in; +} + +.top-left, +.top, +.top-right { + top: 56px; +} + +.bottom-left, +.bottom, +.bottom-right { + bottom: 48px; +} + +.top-left, +.bottom-left { + left: 24px; +} + +.top-right, +.bottom-right { + right: 24px; +} + +.top, +.bottom { + left: 50%; + transform: translateX(-50%); +} + +.title { + overflow: hidden; + text-overflow: ellipsis; + font-weight: 600; +} + +.shortcut { + color: var(--fg-secondary); +} + +.keymap { + color: var(--fg-muted); +} + +.small { + font-size: 15px; +} + +.medium { + font-size: 22px; +} + +.large { + font-size: 32px; +} + +.small .shortcut, +.small .keymap { + font-size: 13px; +} + +.medium .shortcut, +.medium .keymap { + font-size: 18px; +} + +.large .shortcut, +.large .keymap { + font-size: 26px; +} + +@keyframes fade-in { + from { + opacity: 0; + } +} + +@media (prefers-reduced-motion: reduce) { + .popup { + animation: none; + } + + .leaving { + transition: none; + } +} diff --git a/src/features/settings/presentation/PresentationAssistant.tsx b/src/features/settings/presentation/PresentationAssistant.tsx new file mode 100644 index 000000000..f9ceaf5f1 --- /dev/null +++ b/src/features/settings/presentation/PresentationAssistant.tsx @@ -0,0 +1,65 @@ +import { useEffect, useMemo, useRef, useState } from "react"; +import { onActionExecuted } from "@/platform/actions"; +import { useProject } from "@/platform/project"; +import { validateSettings } from "../model/schema"; +import { presentAction, type PresentedAction } from "./presentation"; +import styles from "./PresentationAssistant.module.css"; + +const FADE_MS = 300; + +/** Appearance › Presentation Assistant: the name and shortcut of each action the user runs. */ +export function PresentationAssistant() { + const raw = useProject((s) => s.settings); + const settings = useMemo(() => validateSettings(raw).appearance.presentationAssistant, [raw]); + const [shown, setShown] = useState<{ action: PresentedAction; key: number; leaving: boolean } | null>(null); + const timers = useRef[]>([]); + const { enabled, durationSeconds, alternateKeymap } = settings; + + useEffect(() => { + if (!enabled) return; + let key = 0; + const clear = () => { + for (const t of timers.current) clearTimeout(t); + timers.current = []; + }; + const off = onActionExecuted((id) => { + const action = presentAction(id, alternateKeymap); + if (!action) return; + clear(); + const current = ++key; + setShown({ action, key: current, leaving: false }); + const hold = Math.max(0, durationSeconds * 1000 - FADE_MS); + timers.current.push( + setTimeout(() => setShown((s) => (s?.key === current ? { ...s, leaving: true } : s)), hold), + setTimeout(() => setShown((s) => (s?.key === current ? null : s)), hold + FADE_MS), + ); + }); + return () => { + off(); + clear(); + // A popup whose timers were just cleared would otherwise stay up. + setShown(null); + }; + }, [enabled, durationSeconds, alternateKeymap]); + + if (!enabled || !shown) return null; + const { action, leaving } = shown; + return ( +
+ {action.title} + {action.shortcut && {action.shortcut}} + {action.alternate && ( + + {action.alternate.shortcut} ({action.alternate.keymap}) + + )} +
+ ); +} diff --git a/src/features/settings/presentation/presentation.ts b/src/features/settings/presentation/presentation.ts new file mode 100644 index 000000000..538523c29 --- /dev/null +++ b/src/features/settings/presentation/presentation.ts @@ -0,0 +1,43 @@ +/** + * Presentation Assistant: what to show for an action the user ran, its name and shortcut, and + * optionally the shortcut in the other platform's keymap (macOS ⇄ Windows/Linux). + */ +import { getAction } from "@/platform/actions"; +import { tx } from "@/platform/i18n"; +import { + formatBinding, + isMacHost, + isMouseBinding, + presetBindings, + primaryKeyBinding, + PRESETS, + useKeymap, +} from "@/platform/keymap"; + +export interface PresentedAction { + title: string; + shortcut?: string; + /** The shortcut in the other platform's keymap, with that platform's name. */ + alternate?: { keymap: string; shortcut: string }; +} + +/** The same keymap family on the other platform (`intellij-macos` ⇄ `intellij-windows`). */ +export function alternatePreset(preset: string, mac: boolean): string { + const swapped = mac ? preset.replace(/-macos$/, "-windows") : preset.replace(/-windows$/, "-macos"); + if (swapped !== preset && swapped in PRESETS) return swapped; + return mac ? "intellij-windows" : "intellij-macos"; +} + +export function presentAction(id: string, alternateKeymap: boolean, mac = isMacHost()): PresentedAction | null { + const action = getAction(id); + // Hidden actions are internal steps (accepting a completion, focusing the editor), not commands. + if (!action || action.hidden) return null; + const title = action.verbatim ? action.title : tx(action.title); + const binding = primaryKeyBinding(id); + const presented: PresentedAction = { title, shortcut: binding ? formatBinding(binding, mac) : undefined }; + if (alternateKeymap) { + const other = presetBindings(alternatePreset(useKeymap.getState().preset, mac), id).find((b) => !isMouseBinding(b)); + if (other) presented.alternate = { keymap: mac ? "Windows/Linux" : "macOS", shortcut: formatBinding(other, !mac) }; + } + return presented; +} diff --git a/src/platform/locales/en.json b/src/platform/locales/en.json index 9946d2a03..7744f18cb 100644 --- a/src/platform/locales/en.json +++ b/src/platform/locales/en.json @@ -442,6 +442,7 @@ "menu.navigate.nextBookmark": "Next Bookmark", "menu.navigate.prevBookmark": "Previous Bookmark", "menu.view.toggleCompactMode": "Compact Mode", + "menu.view.togglePresentationAssistant": "Presentation Assistant", "menu.view.zoomIn": "Zoom In IDE", "menu.view.zoomOut": "Zoom Out IDE", "menu.view.resetZoom": "Reset IDE Zoom", diff --git a/src/platform/locales/text/en.json b/src/platform/locales/text/en.json index 3e1f07cde..fbdd848fc 100644 --- a/src/platform/locales/text/en.json +++ b/src/platform/locales/text/en.json @@ -1,4 +1,16 @@ { + "Presentation Assistant": "Presentation Assistant", + "Small": "Small", + "Large": "Large", + "Top center": "Top center", + "Bottom center": "Bottom center", + "Show action names and shortcuts": "Show action names and shortcuts", + "Each action you run shows its name and shortcut in a popup, for screencasts and demos.": "Each action you run shows its name and shortcut in a popup, for screencasts and demos.", + "Popup size": "Popup size", + "Duration": "Duration", + "Popup position": "Popup position", + "Also show the other platform's shortcut": "Also show the other platform's shortcut", + "macOS shortcuts on Windows and Linux, Windows/Linux shortcuts on macOS.": "macOS shortcuts on Windows and Linux, Windows/Linux shortcuts on macOS.", "Trust Project in Codex": "Trust Project in Codex", "Go to Feign Endpoint": "Go to Feign Endpoint", "Choose Feign Endpoint": "Choose Feign Endpoint", diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json index 268ef1ed0..76bd7e091 100644 --- a/src/platform/locales/text/zh.json +++ b/src/platform/locales/text/zh.json @@ -1,4 +1,16 @@ { + "Presentation Assistant": "演示助手", + "Small": "小", + "Large": "大", + "Top center": "顶部居中", + "Bottom center": "底部居中", + "Show action names and shortcuts": "显示操作名称和快捷键", + "Each action you run shows its name and shortcut in a popup, for screencasts and demos.": "每次执行操作时在弹出窗口中显示其名称和快捷键,适合录屏和演示。", + "Popup size": "弹出窗口大小", + "Duration": "持续时间", + "Popup position": "弹出窗口位置", + "Also show the other platform's shortcut": "同时显示另一平台的快捷键", + "macOS shortcuts on Windows and Linux, Windows/Linux shortcuts on macOS.": "在 Windows 和 Linux 上显示 macOS 快捷键,在 macOS 上显示 Windows/Linux 快捷键。", "Trust Project in Codex": "在 Codex 中信任项目", "Go to Feign Endpoint": "跳转到 Feign 端点", "Choose Feign Endpoint": "选择 Feign 端点", diff --git a/src/platform/locales/zh.json b/src/platform/locales/zh.json index aa8f3fef9..a4340f992 100644 --- a/src/platform/locales/zh.json +++ b/src/platform/locales/zh.json @@ -442,6 +442,7 @@ "menu.navigate.nextBookmark": "下一个书签", "menu.navigate.prevBookmark": "上一个书签", "menu.view.toggleCompactMode": "紧凑模式", + "menu.view.togglePresentationAssistant": "演示助手", "menu.view.zoomIn": "放大 IDE", "menu.view.zoomOut": "缩小 IDE", "menu.view.resetZoom": "重置 IDE 缩放",