@theia/keymaps 1.45.0 → 1.46.0-next.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,276 +1,276 @@
1
- /// <reference types="lodash" />
2
- /// <reference types="react" />
3
- import React = require('@theia/core/shared/react');
4
- import { Emitter, Event } from '@theia/core/lib/common/event';
5
- import { CommandRegistry, Command } from '@theia/core/lib/common/command';
6
- import { Keybinding } from '@theia/core/lib/common/keybinding';
7
- import { ReactWidget } from '@theia/core/lib/browser/widgets/react-widget';
8
- import { KeybindingRegistry, Message, ScopedKeybinding, StatefulWidget, Widget, ContextMenuRenderer } from '@theia/core/lib/browser';
9
- import { KeymapsService } from './keymaps-service';
10
- import { DisposableCollection } from '@theia/core';
11
- /**
12
- * Representation of a keybinding item for the view.
13
- */
14
- export interface KeybindingItem {
15
- command: Command;
16
- keybinding?: ScopedKeybinding;
17
- /** human-readable labels can contain highlighting */
18
- labels: {
19
- id: RenderableLabel;
20
- command: RenderableLabel;
21
- keybinding: RenderableLabel;
22
- context: RenderableLabel;
23
- source: RenderableLabel;
24
- };
25
- visible?: boolean;
26
- }
27
- export declare namespace KeybindingItem {
28
- function is(arg: unknown): arg is KeybindingItem;
29
- function keybinding(item: KeybindingItem): Keybinding;
30
- }
31
- export interface RenderableLabel {
32
- readonly value: string;
33
- segments?: RenderableStringSegment[];
34
- }
35
- export interface RenderableStringSegment {
36
- value: string;
37
- match: boolean;
38
- key?: boolean;
39
- }
40
- /**
41
- * Representation of an individual table cell.
42
- */
43
- export interface CellData {
44
- /**
45
- * The cell value.
46
- */
47
- value: string;
48
- /**
49
- * Indicates if a cell's value is currently highlighted.
50
- */
51
- highlighted: boolean;
52
- }
53
- export declare class KeybindingWidget extends ReactWidget implements StatefulWidget {
54
- protected readonly commandRegistry: CommandRegistry;
55
- protected readonly keybindingRegistry: KeybindingRegistry;
56
- protected readonly keymapsService: KeymapsService;
57
- protected readonly contextMenuRenderer: ContextMenuRenderer;
58
- static readonly ID = "keybindings.view.widget";
59
- static readonly LABEL: string;
60
- static readonly CONTEXT_MENU: string[];
61
- static readonly COPY_MENU: string[];
62
- static readonly EDIT_MENU: string[];
63
- static readonly ADD_MENU: string[];
64
- static readonly REMOVE_MENU: string[];
65
- static readonly SHOW_MENU: string[];
66
- /**
67
- * The list of all available keybindings.
68
- */
69
- protected items: KeybindingItem[];
70
- /**
71
- * The current user search query.
72
- */
73
- protected query: string;
74
- /**
75
- * The regular expression used to extract values between fuzzy results.
76
- */
77
- protected readonly regexp: RegExp;
78
- /**
79
- * The regular expression used to extract values between the keybinding separator.
80
- */
81
- protected readonly keybindingSeparator: RegExp;
82
- /**
83
- * The fuzzy search options.
84
- * The `pre` and `post` options are used to wrap fuzzy matches.
85
- */
86
- protected readonly fuzzyOptions: {
87
- pre: string;
88
- post: string;
89
- };
90
- protected readonly onDidUpdateEmitter: Emitter<void>;
91
- readonly onDidUpdate: Event<void>;
92
- protected readonly onRenderCallbacks: DisposableCollection;
93
- protected onRender: () => void;
94
- /**
95
- * Search keybindings.
96
- */
97
- protected readonly searchKeybindings: () => void;
98
- constructor(options?: Widget.IOptions);
99
- /**
100
- * Initialize the widget.
101
- */
102
- protected init(): void;
103
- protected updateItemsAndRerender: import("lodash").DebouncedFunc<() => void>;
104
- /**
105
- * Determine if there currently is a search term.
106
- * @returns `true` if a search term is present.
107
- */
108
- hasSearch(): boolean;
109
- /**
110
- * Clear the search and reset the view.
111
- */
112
- clearSearch(): void;
113
- /**
114
- * Show keybinding items with the same key sequence as the given item.
115
- * @param item the keybinding item
116
- */
117
- showSameKeybindings(item: KeybindingItem): void;
118
- protected onActivateRequest(msg: Message): void;
119
- /**
120
- * Perform a search based on the user's search query.
121
- */
122
- protected doSearchKeybindings(): void;
123
- protected formatAndMatchCommand(item: KeybindingItem): boolean;
124
- protected formatAndMatchKeybinding(item: KeybindingItem, queryItems: string[], exactMatch?: boolean): boolean;
125
- protected formatAndMatchContext(item: KeybindingItem): boolean;
126
- protected formatAndMatchSource(item: KeybindingItem): boolean;
127
- protected toRenderableLabel(label: string, query?: string): RenderableLabel;
128
- /**
129
- * Get the search input if available.
130
- * @returns the search input if available.
131
- */
132
- protected findSearchField(): HTMLInputElement | null;
133
- /**
134
- * Set the focus the search input field if available.
135
- */
136
- protected focusInputField(): void;
137
- /**
138
- * Render the view.
139
- */
140
- protected render(): React.ReactNode;
141
- /**
142
- * Render the search container with the search input.
143
- */
144
- protected renderSearch(): React.ReactNode;
145
- /**
146
- * Render the warning message when no search results are found.
147
- */
148
- protected renderMessage(): React.ReactNode;
149
- /**
150
- * Render the keybindings table.
151
- */
152
- protected renderTable(): React.ReactNode;
153
- /**
154
- * Render the table rows.
155
- */
156
- protected renderRows(): React.ReactNode;
157
- protected renderRow(item: KeybindingItem, index: number): React.ReactNode;
158
- protected handleItemClick(item: KeybindingItem, index: number, event: React.MouseEvent<HTMLElement>): void;
159
- protected handleItemDoubleClick(item: KeybindingItem, index: number, event: React.MouseEvent<HTMLElement>): void;
160
- protected handleItemContextMenu(item: KeybindingItem, index: number, event: React.MouseEvent<HTMLElement>): void;
161
- protected selectItem(item: KeybindingItem, index: number, element: HTMLElement): void;
162
- /**
163
- * Render the actions container with action icons.
164
- * @param item the keybinding item for the row.
165
- */
166
- protected renderActions(item: KeybindingItem): React.ReactNode;
167
- /**
168
- * Render the edit action used to update a keybinding.
169
- * @param item the keybinding item for the row.
170
- */
171
- protected renderEdit(item: KeybindingItem): React.ReactNode;
172
- /**
173
- * Render the reset action to reset the custom keybinding.
174
- * Only visible if a keybinding has a `user` scope.
175
- * @param item the keybinding item for the row.
176
- */
177
- protected renderReset(item: KeybindingItem): React.ReactNode;
178
- /**
179
- * Render the keybinding.
180
- * @param keybinding the keybinding value.
181
- */
182
- protected renderKeybinding(keybinding: KeybindingItem): React.ReactNode;
183
- /**
184
- * Get the list of keybinding items.
185
- *
186
- * @returns the list of keybinding items.
187
- */
188
- protected getItems(): KeybindingItem[];
189
- protected createKeybindingItem(command: Command, keybinding?: ScopedKeybinding): KeybindingItem;
190
- /**
191
- * @returns the input array, sorted.
192
- * The sort priority is as follows: items with keybindings before those without, then alphabetical by command.
193
- */
194
- protected sortKeybindings(bindings: KeybindingItem[]): KeybindingItem[];
195
- /**
196
- * Get the human-readable label for a given command.
197
- * @param command the command.
198
- *
199
- * @returns a human-readable label for the given command.
200
- */
201
- protected getCommandLabel(command: Command): string;
202
- protected getKeybindingLabel(keybinding: ScopedKeybinding | undefined): string | undefined;
203
- protected getContextLabel(keybinding: ScopedKeybinding | undefined): string | undefined;
204
- protected getScopeLabel(keybinding: ScopedKeybinding | undefined): string | undefined;
205
- /**
206
- * Compare two commands.
207
- * - Commands with a label should be prioritized and alphabetically sorted.
208
- * - Commands without a label (id) should be placed at the bottom.
209
- * @param a the first command.
210
- * @param b the second command.
211
- *
212
- * @returns an integer indicating whether `a` comes before, after or is equivalent to `b`.
213
- * - returns `-1` if `a` occurs before `b`.
214
- * - returns `1` if `a` occurs after `b`.
215
- * - returns `0` if they are equivalent.
216
- */
217
- protected compareItem(a: Command, b: Command): number;
218
- /**
219
- * Prompt users to update the keybinding for the given command.
220
- * @param item the keybinding item.
221
- */
222
- editKeybinding(item: KeybindingItem): void;
223
- /**
224
- * Prompt users to update when expression for the given keybinding.
225
- * @param item the keybinding item
226
- */
227
- editWhenExpression(item: KeybindingItem): void;
228
- /**
229
- * Prompt users to add a keybinding for the given command.
230
- * @param item the keybinding item
231
- */
232
- addKeybinding(item: KeybindingItem): void;
233
- /**
234
- * Prompt users for confirmation before resetting.
235
- * @param command the command label.
236
- *
237
- * @returns a Promise which resolves to `true` if a user accepts resetting.
238
- */
239
- protected confirmResetKeybinding(item: KeybindingItem): Promise<boolean>;
240
- /**
241
- * Reset the keybinding to its default value.
242
- * @param item the keybinding item.
243
- */
244
- resetKeybinding(item: KeybindingItem): Promise<void>;
245
- /**
246
- * Whether the keybinding can be reset to its default value.
247
- * @param item the keybinding item
248
- */
249
- canResetKeybinding(item: KeybindingItem): boolean;
250
- /**
251
- * Validate the provided keybinding value against its previous value.
252
- * @param command the command label.
253
- * @param oldKeybinding the old keybinding value.
254
- * @param keybinding the new keybinding value.
255
- *
256
- * @returns the end user message to display.
257
- */
258
- protected validateKeybinding(command: string, oldKeybinding: string | undefined, keybinding: string): string;
259
- /**
260
- * Build the cell data with highlights if applicable.
261
- * @param raw the raw cell value.
262
- *
263
- * @returns the list of cell data.
264
- */
265
- protected buildCellData(raw: string): CellData[];
266
- /**
267
- * Render the fuzzy representation of a matched result.
268
- * @param property one of the `KeybindingItem` properties.
269
- */
270
- protected renderMatchedData(property: RenderableLabel): React.ReactNode;
271
- storeState(): object | undefined;
272
- restoreState(oldState: {
273
- query: string;
274
- }): void;
275
- }
1
+ /// <reference types="lodash" />
2
+ /// <reference types="react" />
3
+ import React = require('@theia/core/shared/react');
4
+ import { Emitter, Event } from '@theia/core/lib/common/event';
5
+ import { CommandRegistry, Command } from '@theia/core/lib/common/command';
6
+ import { Keybinding } from '@theia/core/lib/common/keybinding';
7
+ import { ReactWidget } from '@theia/core/lib/browser/widgets/react-widget';
8
+ import { KeybindingRegistry, Message, ScopedKeybinding, StatefulWidget, Widget, ContextMenuRenderer } from '@theia/core/lib/browser';
9
+ import { KeymapsService } from './keymaps-service';
10
+ import { DisposableCollection } from '@theia/core';
11
+ /**
12
+ * Representation of a keybinding item for the view.
13
+ */
14
+ export interface KeybindingItem {
15
+ command: Command;
16
+ keybinding?: ScopedKeybinding;
17
+ /** human-readable labels can contain highlighting */
18
+ labels: {
19
+ id: RenderableLabel;
20
+ command: RenderableLabel;
21
+ keybinding: RenderableLabel;
22
+ context: RenderableLabel;
23
+ source: RenderableLabel;
24
+ };
25
+ visible?: boolean;
26
+ }
27
+ export declare namespace KeybindingItem {
28
+ function is(arg: unknown): arg is KeybindingItem;
29
+ function keybinding(item: KeybindingItem): Keybinding;
30
+ }
31
+ export interface RenderableLabel {
32
+ readonly value: string;
33
+ segments?: RenderableStringSegment[];
34
+ }
35
+ export interface RenderableStringSegment {
36
+ value: string;
37
+ match: boolean;
38
+ key?: boolean;
39
+ }
40
+ /**
41
+ * Representation of an individual table cell.
42
+ */
43
+ export interface CellData {
44
+ /**
45
+ * The cell value.
46
+ */
47
+ value: string;
48
+ /**
49
+ * Indicates if a cell's value is currently highlighted.
50
+ */
51
+ highlighted: boolean;
52
+ }
53
+ export declare class KeybindingWidget extends ReactWidget implements StatefulWidget {
54
+ protected readonly commandRegistry: CommandRegistry;
55
+ protected readonly keybindingRegistry: KeybindingRegistry;
56
+ protected readonly keymapsService: KeymapsService;
57
+ protected readonly contextMenuRenderer: ContextMenuRenderer;
58
+ static readonly ID = "keybindings.view.widget";
59
+ static readonly LABEL: string;
60
+ static readonly CONTEXT_MENU: string[];
61
+ static readonly COPY_MENU: string[];
62
+ static readonly EDIT_MENU: string[];
63
+ static readonly ADD_MENU: string[];
64
+ static readonly REMOVE_MENU: string[];
65
+ static readonly SHOW_MENU: string[];
66
+ /**
67
+ * The list of all available keybindings.
68
+ */
69
+ protected items: KeybindingItem[];
70
+ /**
71
+ * The current user search query.
72
+ */
73
+ protected query: string;
74
+ /**
75
+ * The regular expression used to extract values between fuzzy results.
76
+ */
77
+ protected readonly regexp: RegExp;
78
+ /**
79
+ * The regular expression used to extract values between the keybinding separator.
80
+ */
81
+ protected readonly keybindingSeparator: RegExp;
82
+ /**
83
+ * The fuzzy search options.
84
+ * The `pre` and `post` options are used to wrap fuzzy matches.
85
+ */
86
+ protected readonly fuzzyOptions: {
87
+ pre: string;
88
+ post: string;
89
+ };
90
+ protected readonly onDidUpdateEmitter: Emitter<void>;
91
+ readonly onDidUpdate: Event<void>;
92
+ protected readonly onRenderCallbacks: DisposableCollection;
93
+ protected onRender: () => void;
94
+ /**
95
+ * Search keybindings.
96
+ */
97
+ protected readonly searchKeybindings: () => void;
98
+ constructor(options?: Widget.IOptions);
99
+ /**
100
+ * Initialize the widget.
101
+ */
102
+ protected init(): void;
103
+ protected updateItemsAndRerender: import("lodash").DebouncedFunc<() => void>;
104
+ /**
105
+ * Determine if there currently is a search term.
106
+ * @returns `true` if a search term is present.
107
+ */
108
+ hasSearch(): boolean;
109
+ /**
110
+ * Clear the search and reset the view.
111
+ */
112
+ clearSearch(): void;
113
+ /**
114
+ * Show keybinding items with the same key sequence as the given item.
115
+ * @param item the keybinding item
116
+ */
117
+ showSameKeybindings(item: KeybindingItem): void;
118
+ protected onActivateRequest(msg: Message): void;
119
+ /**
120
+ * Perform a search based on the user's search query.
121
+ */
122
+ protected doSearchKeybindings(): void;
123
+ protected formatAndMatchCommand(item: KeybindingItem): boolean;
124
+ protected formatAndMatchKeybinding(item: KeybindingItem, queryItems: string[], exactMatch?: boolean): boolean;
125
+ protected formatAndMatchContext(item: KeybindingItem): boolean;
126
+ protected formatAndMatchSource(item: KeybindingItem): boolean;
127
+ protected toRenderableLabel(label: string, query?: string): RenderableLabel;
128
+ /**
129
+ * Get the search input if available.
130
+ * @returns the search input if available.
131
+ */
132
+ protected findSearchField(): HTMLInputElement | null;
133
+ /**
134
+ * Set the focus the search input field if available.
135
+ */
136
+ protected focusInputField(): void;
137
+ /**
138
+ * Render the view.
139
+ */
140
+ protected render(): React.ReactNode;
141
+ /**
142
+ * Render the search container with the search input.
143
+ */
144
+ protected renderSearch(): React.ReactNode;
145
+ /**
146
+ * Render the warning message when no search results are found.
147
+ */
148
+ protected renderMessage(): React.ReactNode;
149
+ /**
150
+ * Render the keybindings table.
151
+ */
152
+ protected renderTable(): React.ReactNode;
153
+ /**
154
+ * Render the table rows.
155
+ */
156
+ protected renderRows(): React.ReactNode;
157
+ protected renderRow(item: KeybindingItem, index: number): React.ReactNode;
158
+ protected handleItemClick(item: KeybindingItem, index: number, event: React.MouseEvent<HTMLElement>): void;
159
+ protected handleItemDoubleClick(item: KeybindingItem, index: number, event: React.MouseEvent<HTMLElement>): void;
160
+ protected handleItemContextMenu(item: KeybindingItem, index: number, event: React.MouseEvent<HTMLElement>): void;
161
+ protected selectItem(item: KeybindingItem, index: number, element: HTMLElement): void;
162
+ /**
163
+ * Render the actions container with action icons.
164
+ * @param item the keybinding item for the row.
165
+ */
166
+ protected renderActions(item: KeybindingItem): React.ReactNode;
167
+ /**
168
+ * Render the edit action used to update a keybinding.
169
+ * @param item the keybinding item for the row.
170
+ */
171
+ protected renderEdit(item: KeybindingItem): React.ReactNode;
172
+ /**
173
+ * Render the reset action to reset the custom keybinding.
174
+ * Only visible if a keybinding has a `user` scope.
175
+ * @param item the keybinding item for the row.
176
+ */
177
+ protected renderReset(item: KeybindingItem): React.ReactNode;
178
+ /**
179
+ * Render the keybinding.
180
+ * @param keybinding the keybinding value.
181
+ */
182
+ protected renderKeybinding(keybinding: KeybindingItem): React.ReactNode;
183
+ /**
184
+ * Get the list of keybinding items.
185
+ *
186
+ * @returns the list of keybinding items.
187
+ */
188
+ protected getItems(): KeybindingItem[];
189
+ protected createKeybindingItem(command: Command, keybinding?: ScopedKeybinding): KeybindingItem;
190
+ /**
191
+ * @returns the input array, sorted.
192
+ * The sort priority is as follows: items with keybindings before those without, then alphabetical by command.
193
+ */
194
+ protected sortKeybindings(bindings: KeybindingItem[]): KeybindingItem[];
195
+ /**
196
+ * Get the human-readable label for a given command.
197
+ * @param command the command.
198
+ *
199
+ * @returns a human-readable label for the given command.
200
+ */
201
+ protected getCommandLabel(command: Command): string;
202
+ protected getKeybindingLabel(keybinding: ScopedKeybinding | undefined): string | undefined;
203
+ protected getContextLabel(keybinding: ScopedKeybinding | undefined): string | undefined;
204
+ protected getScopeLabel(keybinding: ScopedKeybinding | undefined): string | undefined;
205
+ /**
206
+ * Compare two commands.
207
+ * - Commands with a label should be prioritized and alphabetically sorted.
208
+ * - Commands without a label (id) should be placed at the bottom.
209
+ * @param a the first command.
210
+ * @param b the second command.
211
+ *
212
+ * @returns an integer indicating whether `a` comes before, after or is equivalent to `b`.
213
+ * - returns `-1` if `a` occurs before `b`.
214
+ * - returns `1` if `a` occurs after `b`.
215
+ * - returns `0` if they are equivalent.
216
+ */
217
+ protected compareItem(a: Command, b: Command): number;
218
+ /**
219
+ * Prompt users to update the keybinding for the given command.
220
+ * @param item the keybinding item.
221
+ */
222
+ editKeybinding(item: KeybindingItem): void;
223
+ /**
224
+ * Prompt users to update when expression for the given keybinding.
225
+ * @param item the keybinding item
226
+ */
227
+ editWhenExpression(item: KeybindingItem): void;
228
+ /**
229
+ * Prompt users to add a keybinding for the given command.
230
+ * @param item the keybinding item
231
+ */
232
+ addKeybinding(item: KeybindingItem): void;
233
+ /**
234
+ * Prompt users for confirmation before resetting.
235
+ * @param command the command label.
236
+ *
237
+ * @returns a Promise which resolves to `true` if a user accepts resetting.
238
+ */
239
+ protected confirmResetKeybinding(item: KeybindingItem): Promise<boolean>;
240
+ /**
241
+ * Reset the keybinding to its default value.
242
+ * @param item the keybinding item.
243
+ */
244
+ resetKeybinding(item: KeybindingItem): Promise<void>;
245
+ /**
246
+ * Whether the keybinding can be reset to its default value.
247
+ * @param item the keybinding item
248
+ */
249
+ canResetKeybinding(item: KeybindingItem): boolean;
250
+ /**
251
+ * Validate the provided keybinding value against its previous value.
252
+ * @param command the command label.
253
+ * @param oldKeybinding the old keybinding value.
254
+ * @param keybinding the new keybinding value.
255
+ *
256
+ * @returns the end user message to display.
257
+ */
258
+ protected validateKeybinding(command: string, oldKeybinding: string | undefined, keybinding: string): string;
259
+ /**
260
+ * Build the cell data with highlights if applicable.
261
+ * @param raw the raw cell value.
262
+ *
263
+ * @returns the list of cell data.
264
+ */
265
+ protected buildCellData(raw: string): CellData[];
266
+ /**
267
+ * Render the fuzzy representation of a matched result.
268
+ * @param property one of the `KeybindingItem` properties.
269
+ */
270
+ protected renderMatchedData(property: RenderableLabel): React.ReactNode;
271
+ storeState(): object | undefined;
272
+ restoreState(oldState: {
273
+ query: string;
274
+ }): void;
275
+ }
276
276
  //# sourceMappingURL=keybindings-widget.d.ts.map