import type { Toggle } from "./dbusmenu"; import { MenuEntryKind } from "./dbusmenu"; export { MenuEntryKind, ToggleKind } from "./dbusmenu"; /** The keys that run an entry, as Electron's accelerators name them. */ export type Accelerator = { ctrl: boolean; alt: boolean; shift: boolean; /** The Super key, which Electron also calls Meta. */ meta: boolean; /** * The key, by where it is on a US keyboard as Chromium's accelerators go: * an uppercase letter, a digit, the character a punctuation key types * unshifted, or a `KeyboardEvent.key` name such as `ArrowUp` or `F5`. */ key: string; /** How a menu shows it, such as `Ctrl+Shift+N`. */ label: string; }; /** One thing the menu can do, or a submenu. */ export type AppMenuItem = { /** What `browser.clickMenu` names it by. */ id: number; /** Its text, with the mnemonic's `&` removed. */ label: string; /** Where in `label` the access key is, if an `&` marked one. */ mnemonic: number | undefined; enabled: boolean; /** The app's picture for it, as a PNG `data:` URL. */ icon: string | undefined; toggle: Toggle | undefined; accelerator: Accelerator | undefined; /** Its entries, for an item that opens a submenu. */ submenu: readonly AppMenuEntry[] | undefined; }; export type AppMenuEntry = (AppMenuItem & { kind: MenuEntryKind.Item; }) | { id: number; kind: MenuEntryKind.Separator; }; /** * The entries of `menu`, a browser window's `menu`, with hidden ones left * out. Throws for a menu the engine should not have listed: it checks each * one the app sends. */ export declare const appMenu: (menu: string) => readonly AppMenuEntry[]; /** An Electron app's popup menu over its window, and where it goes. */ export type AppPopupMenu = { entries: readonly AppMenuEntry[]; /** Where it goes, in CSS pixels from the window's page's top left. */ at: { x: number; y: number; }; }; /** * A window's `popupMenu`, as the engine lists it: `{menu, x, y}`. Throws for * one the engine should have refused. */ export declare const appPopupMenu: (popup: string) => AppPopupMenu; /** * `written`, an Electron accelerator such as `CmdOrCtrl+Shift+N`, or none * when it names a key this can't match: the app's own accelerator, which the * menu then shows no keys for. */ export declare const acceleratorOf: (written: string) => Accelerator | undefined; /** What of a `KeyboardEvent` an accelerator is matched against. */ export type KeyLike = Pick; /** Whether `event` presses `accelerator`'s keys, and no other modifiers. */ export declare const pressesAccelerator: (accelerator: Accelerator, event: KeyLike) => boolean; /** * The enabled entry in `entries`, or in the submenus of enabled ones, whose * accelerator `event` presses: what Electron runs for it. */ export declare const acceleratedBy: (entries: readonly AppMenuEntry[], event: KeyLike) => AppMenuItem | undefined; /** * The top-level entry whose mnemonic `event` presses with Alt alone, as Alt+F * opens a File menu. */ export declare const openedByMnemonic: (entries: readonly AppMenuEntry[], event: KeyLike) => AppMenuItem | undefined;