import { DestroyRef, Injector } from '@angular/core'; import { Subject } from 'rxjs'; import { Element } from '../angular-terminal/dom-terminal'; import { ScreenService } from '../angular-terminal/screen-service'; import { Disposable } from './disposable'; import { Key } from './keypress-parser'; import { LogPointService } from '../logs/LogPointService'; import * as i0 from "@angular/core"; /** * Commands are a function with an `id`. * You can provide a default keybind with `keys`. */ export interface Command { id: string; name: string; keys: string | string[]; func: (key: Key) => Key | void | Promise | Promise; context?: Context; keywords: string; hidden: boolean; } export declare class ShortcutService { _id: number; name: string; /** * Commands are stored by `id`. An `id` can have multiple commands. * This allows components to declare the same `id` without conflict, the latest command is used. * When the second component is destroyed the first command can be restored. */ readonly commands: import("../utils/Signal2").Signal2<{ [id: string]: Command[]; }>; /** * A shortcut links a key (ex: ctrl+r) with a command id (ex: reload) */ readonly shortcuts: import("../utils/Signal2").Signal2<{ [keys: string]: string[]; }>; readonly focusStack: import("../utils/Signal2").Signal2; readonly focusedChild: import("../utils/Signal2").Signal2; readonly children: import("../utils/Signal2").Signal2; readonly components: import("../utils/Signal2").Signal2; readonly rootNode: import("../utils/Signal2").Signal2; readonly receivedCaretRequestRecently: import("../utils/Signal2").Signal2; readonly askedForFocusThisTick: import("../utils/Signal2").Signal2<{ child: ShortcutService; source: ShortcutService; reason: string; }[]>; readonly caretElement: import("../utils/Signal2").Signal2; readonly isFocused: import("../utils/Signal2").Signal2; readonly isInFocusPath: import("../utils/Signal2").Signal2; readonly before: import("../utils/Signal2").Signal2; readonly focusPropagateUp: import("../utils/Signal2").Signal2; readonly focusIf: import("../utils/Signal2").Signal2; injector: Injector; screen: ScreenService; logger: import("../angular-terminal/logger").Logger; parent: ShortcutService; reason: string; private timeout; lp: LogPointService; constructor(); incomingKey(keyEvent: any): void; private propagateKeypress; private handleKeypress; /** * Example: * ``` * register({keys: 'ctrl+r', func: () => { * console.log('ctrl+r was pressed') * }}) * * register({keys: 'else', func: keypress => { * console.log(`${keypress.key} was pressed') * }}) * ``` */ registerCommand(_command: Partial): Disposable; private removeCommand; callCommand(arg: { id: string; keys?: string; args?: any[]; }): any; findCommand(id: string): any; /** * If multiple components request focus at the same time, the first one to request wins. * Usually called inside `ngOnInit`. */ requestFocus(args?: { child?: ShortcutService; soft?: boolean; reason?: string; source?: ShortcutService; }): boolean; /** * Give up the focus. * The next shortcutService in the focusStack gets focused. */ unfocus(child?: ShortcutService): any; /** * Tell our parent that we're getting destroyed. */ ngOnDestroy(): void; destroy$: Subject; /** * Called by children to signal their creation. */ private childCreated; /** * Called by children to signal their destruction. */ private childDestroyed; toString(): string; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } export declare function retrieveLast(map: any, id: any): any; export declare const EmptyCommand: Command; /** * Convert a keypress to a string. * Example: {ctrl: true, key: 'r'} => 'ctrl+r' */ export declare function keyToString(key: Key): string; type Context = { name: string; ref: any; }; /** * Register keybinds for the lifetime of the component */ export declare function registerShortcuts(commands: Partial[], options?: { shortcutService?: ShortcutService; onDestroy?: DestroyRef['onDestroy']; context?: Context; }): void; export declare function getFocusedNode(shortcutService: ShortcutService): ShortcutService; export declare function rgDebugKeybinds(): SimplifiedShortcutService; declare class SimplifiedShortcutService { ref: ShortcutService; children: ShortcutService[]; focusedChild: ShortcutService; commands: { [id: string]: Command[]; }; _id: number; shortcuts: { [keys: string]: string[]; }; constructor(shortcutService: ShortcutService); get parent(): SimplifiedShortcutService; toString(): string; } export declare function padding(shortcutService: ShortcutService): string; export declare function depth(shortcutService: ShortcutService): number; export {};