1 | /**
|
2 | * A Keybinding binds a specific key sequence ({@link Keybinding#keybinding}) to trigger a command ({@link Keybinding#command}). A Keybinding optionally may
|
3 | * define a "when clause" ({@link Keybinding#when}) to specify in which context it becomes active.
|
4 | * @see KeyBindingRegistry
|
5 | */
|
6 | export interface Keybinding {
|
7 | /**
|
8 | * Unique command identifier of the command to be triggered by this keybinding.
|
9 | */
|
10 | command: string;
|
11 | /**
|
12 | * The key sequence for the keybinding as defined in packages/keymaps/README.md.
|
13 | */
|
14 | keybinding: string;
|
15 | /**
|
16 | * The optional keybinding context where this binding belongs to.
|
17 | * If not specified, then this keybinding context belongs to the NOOP
|
18 | * keybinding context.
|
19 | *
|
20 | * @deprecated use `when` closure instead
|
21 | */
|
22 | context?: string;
|
23 | /**
|
24 | * An optional clause defining the condition when the keybinding is active, e.g. based on the current focus.
|
25 | * See {@link https://code.visualstudio.com/docs/getstarted/keybindings#_when-clause-contexts} for more details.
|
26 | */
|
27 | when?: string;
|
28 | /**
|
29 | * Optional arguments that will be passed to the command when it gets triggered via this keybinding.
|
30 | * Needs to be specified when the triggered command expects arguments to be passed to the command handler.
|
31 | */
|
32 | args?: any;
|
33 | }
|
34 | export declare namespace Keybinding {
|
35 | /**
|
36 | * Compares two keybindings for equality.
|
37 | * Can optionally ignore the keybinding and/or args property in the comparison.
|
38 | * @param a The first Keybinding in the comparison
|
39 | * @param b The second Keybinding in the comparison
|
40 | * @param ignoreKeybinding Ignore the 'keybinding' property in the comparison
|
41 | * @param ignoreArgs Ignore the 'args' property in the comparison
|
42 | */
|
43 | function equals(a: Keybinding, b: Keybinding, ignoreKeybinding?: boolean, ignoreArgs?: boolean): boolean;
|
44 | /**
|
45 | * Returns a new object only containing properties which
|
46 | * are described on the `Keybinding` API.
|
47 | *
|
48 | * @param binding the binding to create an API object for.
|
49 | */
|
50 | function apiObjectify(binding: Keybinding | RawKeybinding): Keybinding;
|
51 | function retrieveKeybinding(binding: Partial<Keybinding & RawKeybinding>): string;
|
52 | /**
|
53 | * Returns with the string representation of the binding.
|
54 | * Any additional properties which are not described on
|
55 | * the `Keybinding` API will be ignored.
|
56 | *
|
57 | * @param binding the binding to stringify.
|
58 | */
|
59 | function stringify(binding: Keybinding): string;
|
60 | function is(arg: unknown): arg is Keybinding;
|
61 | }
|
62 | /**
|
63 | * @internal
|
64 | *
|
65 | * Optional representation of key sequence as found in `keymaps.json` file.
|
66 | * Use `keybinding` as the official representation.
|
67 | */
|
68 | export interface RawKeybinding extends Omit<Keybinding, 'keybinding'> {
|
69 | key: string;
|
70 | }
|
71 | export declare namespace RawKeybinding {
|
72 | function is(candidate: unknown): candidate is RawKeybinding;
|
73 | }
|
74 | //# sourceMappingURL=keybinding.d.ts.map |
\ | No newline at end of file |