blob: 1e13b2ea4545447432689a0a0907e0e2a211dfee [file] [log] [blame]
Blink Reformat4c46d092018-04-07 15:32:371/*
2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31/**
32 * @unrestricted
33 */
34UI.ShortcutsScreen = class {
35 constructor() {
36 /** @type {!Object.<string, !UI.ShortcutsSection>} */
37 this._sections = {};
38 }
39
40 static registerShortcuts() {
41 // Elements panel
42 const elementsSection = UI.shortcutsScreen.section(Common.UIString('Elements Panel'));
43
44 const navigate = UI.ShortcutsScreen.ElementsPanelShortcuts.NavigateUp.concat(
45 UI.ShortcutsScreen.ElementsPanelShortcuts.NavigateDown);
46 elementsSection.addRelatedKeys(navigate, Common.UIString('Navigate elements'));
47
48 const expandCollapse =
49 UI.ShortcutsScreen.ElementsPanelShortcuts.Expand.concat(UI.ShortcutsScreen.ElementsPanelShortcuts.Collapse);
50 elementsSection.addRelatedKeys(expandCollapse, Common.UIString('Expand/collapse'));
51
52 elementsSection.addAlternateKeys(
53 UI.ShortcutsScreen.ElementsPanelShortcuts.EditAttribute, Common.UIString('Edit attribute'));
54 elementsSection.addAlternateKeys(
Joel Einbindera66e5bf2018-05-31 01:26:3755 UI.shortcutRegistry.shortcutDescriptorsForAction('elements.hide-element'), Common.UIString('Hide element'));
Blink Reformat4c46d092018-04-07 15:32:3756 elementsSection.addAlternateKeys(
Joel Einbindera66e5bf2018-05-31 01:26:3757 UI.shortcutRegistry.shortcutDescriptorsForAction('elements.edit-as-html'),
58 Common.UIString('Toggle edit as HTML'));
Blink Reformat4c46d092018-04-07 15:32:3759
Fabio Rochaf0d95472019-05-28 21:35:1960 // Styles pane
Blink Reformat4c46d092018-04-07 15:32:3761 const stylesPaneSection = UI.shortcutsScreen.section(Common.UIString('Styles Pane'));
62
63 const nextPreviousProperty = UI.ShortcutsScreen.ElementsPanelShortcuts.NextProperty.concat(
64 UI.ShortcutsScreen.ElementsPanelShortcuts.PreviousProperty);
65 stylesPaneSection.addRelatedKeys(nextPreviousProperty, Common.UIString('Next/previous property'));
66
67 stylesPaneSection.addRelatedKeys(
68 UI.ShortcutsScreen.ElementsPanelShortcuts.IncrementValue, Common.UIString('Increment value'));
69 stylesPaneSection.addRelatedKeys(
70 UI.ShortcutsScreen.ElementsPanelShortcuts.DecrementValue, Common.UIString('Decrement value'));
71
72 stylesPaneSection.addAlternateKeys(
73 UI.ShortcutsScreen.ElementsPanelShortcuts.IncrementBy10, Common.UIString('Increment by %f', 10));
74 stylesPaneSection.addAlternateKeys(
75 UI.ShortcutsScreen.ElementsPanelShortcuts.DecrementBy10, Common.UIString('Decrement by %f', 10));
76
77 stylesPaneSection.addAlternateKeys(
78 UI.ShortcutsScreen.ElementsPanelShortcuts.IncrementBy100, Common.UIString('Increment by %f', 100));
79 stylesPaneSection.addAlternateKeys(
80 UI.ShortcutsScreen.ElementsPanelShortcuts.DecrementBy100, Common.UIString('Decrement by %f', 100));
81
82 stylesPaneSection.addAlternateKeys(
83 UI.ShortcutsScreen.ElementsPanelShortcuts.IncrementBy01, Common.UIString('Increment by %f', 0.1));
84 stylesPaneSection.addAlternateKeys(
85 UI.ShortcutsScreen.ElementsPanelShortcuts.DecrementBy01, Common.UIString('Decrement by %f', 0.1));
86
Fabio Rochaf0d95472019-05-28 21:35:1987 // Console
88 const consoleSection = UI.shortcutsScreen.section(Common.UIString('Console'));
Blink Reformat4c46d092018-04-07 15:32:3789
Fabio Rochaf0d95472019-05-28 21:35:1990 consoleSection.addAlternateKeys(
91 UI.shortcutRegistry.shortcutDescriptorsForAction('console.clear'), Common.UIString('Clear console'));
92 consoleSection.addRelatedKeys(
93 UI.ShortcutsScreen.ConsolePanelShortcuts.AcceptSuggestion, Common.UIString('Accept suggestion'));
94 consoleSection.addAlternateKeys(
95 UI.ShortcutsScreen.ConsolePanelShortcuts.ClearConsolePrompt, Common.UIString('Clear console prompt'));
96 consoleSection.addRelatedKeys(
97 UI.ShortcutsScreen.ConsolePanelShortcuts.NextPreviousLine, Common.UIString('Next/previous line'));
98
99 if (Host.isMac()) {
100 consoleSection.addRelatedKeys(
101 UI.ShortcutsScreen.ConsolePanelShortcuts.NextPreviousCommand, Common.UIString('Next/previous command'));
102 }
103
104 consoleSection.addKey(UI.ShortcutsScreen.ConsolePanelShortcuts.ExecuteCommand, Common.UIString('Execute command'));
105
106 // Debugger
107 const debuggerSection = UI.shortcutsScreen.section(Common.UIString('Debugger'));
108
109 debuggerSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37110 UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.toggle-pause'), Common.UIString('Pause/ Continue'));
Fabio Rochaf0d95472019-05-28 21:35:19111 debuggerSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37112 UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.step-over'), Common.UIString('Step over'));
Fabio Rochaf0d95472019-05-28 21:35:19113 debuggerSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37114 UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.step-into'), Common.UIString('Step into'));
Fabio Rochaf0d95472019-05-28 21:35:19115 debuggerSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37116 UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.step-out'), Common.UIString('Step out'));
117
118 const nextAndPrevFrameKeys =
119 UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.next-call-frame')
120 .concat(UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.previous-call-frame'));
Fabio Rochaf0d95472019-05-28 21:35:19121 debuggerSection.addRelatedKeys(nextAndPrevFrameKeys, Common.UIString('Next/previous call frame'));
Blink Reformat4c46d092018-04-07 15:32:37122
Fabio Rochaf0d95472019-05-28 21:35:19123 debuggerSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37124 UI.ShortcutsScreen.SourcesPanelShortcuts.EvaluateSelectionInConsole,
125 Common.UIString('Evaluate selection in console'));
Fabio Rochaf0d95472019-05-28 21:35:19126 debuggerSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37127 UI.ShortcutsScreen.SourcesPanelShortcuts.AddSelectionToWatch, Common.UIString('Add selection to watch'));
Fabio Rochaf0d95472019-05-28 21:35:19128 debuggerSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37129 UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.toggle-breakpoint'),
130 Common.UIString('Toggle breakpoint'));
Fabio Rochaf0d95472019-05-28 21:35:19131 debuggerSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37132 UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.toggle-breakpoint-enabled'),
133 Common.UIString('Toggle breakpoint enabled'));
Fabio Rochaf0d95472019-05-28 21:35:19134 debuggerSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37135 UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.toggle-breakpoints-active'),
136 Common.UIString('Toggle all breakpoints'));
Olivia Flynn8e746e02019-06-19 17:06:23137 debuggerSection.addAlternateKeys(
138 UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.breakpoint-input-window'),
139 ls`Open breakpoint editor`);
Blink Reformat4c46d092018-04-07 15:32:37140
141 // Editing
Fabio Rochaf0d95472019-05-28 21:35:19142 const editingSection = UI.shortcutsScreen.section(Common.UIString('Text Editor'));
143
144 editingSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37145 UI.shortcutRegistry.shortcutDescriptorsForAction('sources.go-to-member'), Common.UIString('Go to member'));
Fabio Rochaf0d95472019-05-28 21:35:19146 editingSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37147 UI.ShortcutsScreen.SourcesPanelShortcuts.ToggleAutocompletion, Common.UIString('Autocompletion'));
Fabio Rochaf0d95472019-05-28 21:35:19148 editingSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37149 UI.shortcutRegistry.shortcutDescriptorsForAction('sources.go-to-line'), Common.UIString('Go to line'));
Fabio Rochaf0d95472019-05-28 21:35:19150 editingSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37151 UI.shortcutRegistry.shortcutDescriptorsForAction('sources.jump-to-previous-location'),
152 Common.UIString('Jump to previous editing location'));
Fabio Rochaf0d95472019-05-28 21:35:19153 editingSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37154 UI.shortcutRegistry.shortcutDescriptorsForAction('sources.jump-to-next-location'),
155 Common.UIString('Jump to next editing location'));
Fabio Rochaf0d95472019-05-28 21:35:19156 editingSection.addAlternateKeys(
157 UI.ShortcutsScreen.SourcesPanelShortcuts.ToggleComment, Common.UIString('Toggle comment'));
158 editingSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37159 UI.ShortcutsScreen.SourcesPanelShortcuts.IncreaseCSSUnitByOne, Common.UIString('Increment CSS unit by 1'));
Fabio Rochaf0d95472019-05-28 21:35:19160 editingSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37161 UI.ShortcutsScreen.SourcesPanelShortcuts.DecreaseCSSUnitByOne, Common.UIString('Decrement CSS unit by 1'));
Fabio Rochaf0d95472019-05-28 21:35:19162 editingSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37163 UI.ShortcutsScreen.SourcesPanelShortcuts.IncreaseCSSUnitByTen, Common.UIString('Increment CSS unit by 10'));
Fabio Rochaf0d95472019-05-28 21:35:19164 editingSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37165 UI.ShortcutsScreen.SourcesPanelShortcuts.DecreaseCSSUnitByTen, Common.UIString('Decrement CSS unit by 10'));
Fabio Rochaf0d95472019-05-28 21:35:19166 editingSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37167 UI.ShortcutsScreen.SourcesPanelShortcuts.SelectNextOccurrence, Common.UIString('Select next occurrence'));
Fabio Rochaf0d95472019-05-28 21:35:19168 editingSection.addAlternateKeys(UI.ShortcutsScreen.SourcesPanelShortcuts.SoftUndo, Common.UIString('Soft undo'));
169 editingSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37170 UI.ShortcutsScreen.SourcesPanelShortcuts.GotoMatchingBracket, Common.UIString('Go to matching bracket'));
Fabio Rochaf0d95472019-05-28 21:35:19171 editingSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37172 UI.shortcutRegistry.shortcutDescriptorsForAction('sources.close-editor-tab'),
173 Common.UIString('Close editor tab'));
Fabio Rochaf0d95472019-05-28 21:35:19174 editingSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37175 UI.shortcutRegistry.shortcutDescriptorsForAction('sources.switch-file'),
176 Common.UIString('Switch between files with the same name and different extensions.'));
177
178 // Performance panel
Fabio Rochaf0d95472019-05-28 21:35:19179 const performanceSection = UI.shortcutsScreen.section(Common.UIString('Performance Panel'));
180
181 performanceSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37182 UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.toggle-recording'),
183 Common.UIString('Start/stop recording'));
Fabio Rochaf0d95472019-05-28 21:35:19184 performanceSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37185 UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.record-reload'),
186 Common.UIString('Record page reload'));
Fabio Rochaf0d95472019-05-28 21:35:19187 performanceSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37188 UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.save-to-file'), Common.UIString('Save profile'));
Fabio Rochaf0d95472019-05-28 21:35:19189 performanceSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37190 UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.load-from-file'), Common.UIString('Load profile'));
Fabio Rochaf0d95472019-05-28 21:35:19191 performanceSection.addRelatedKeys(
Blink Reformat4c46d092018-04-07 15:32:37192 UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.jump-to-previous-frame')
193 .concat(UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.jump-to-next-frame')),
194 Common.UIString('Jump to previous/next frame'));
Fabio Rochaf0d95472019-05-28 21:35:19195 performanceSection.addRelatedKeys(
Blink Reformat4c46d092018-04-07 15:32:37196 UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.show-history'),
197 Common.UIString('Pick a recording from history'));
Fabio Rochaf0d95472019-05-28 21:35:19198 performanceSection.addRelatedKeys(
Blink Reformat4c46d092018-04-07 15:32:37199 UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.previous-recording')
200 .concat(UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.next-recording')),
201 Common.UIString('Show previous/next recording'));
202
203 // Memory panel
Fabio Rochaf0d95472019-05-28 21:35:19204 const memorySection = UI.shortcutsScreen.section(Common.UIString('Memory Panel'));
205
206 memorySection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37207 UI.shortcutRegistry.shortcutDescriptorsForAction('profiler.heap-toggle-recording'),
208 Common.UIString('Start/stop recording'));
209
210 // Layers panel
Fabio Rochaf0d95472019-05-28 21:35:19211 const layersSection = UI.shortcutsScreen.section(Common.UIString('Layers Panel'));
212
213 layersSection.addAlternateKeys(UI.ShortcutsScreen.LayersPanelShortcuts.ResetView, Common.UIString('Reset view'));
214 layersSection.addAlternateKeys(
215 UI.ShortcutsScreen.LayersPanelShortcuts.PanMode, Common.UIString('Switch to pan mode'));
216 layersSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37217 UI.ShortcutsScreen.LayersPanelShortcuts.RotateMode, Common.UIString('Switch to rotate mode'));
Fabio Rochaf0d95472019-05-28 21:35:19218 layersSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37219 UI.ShortcutsScreen.LayersPanelShortcuts.TogglePanRotate,
220 Common.UIString('Temporarily toggle pan/rotate mode while held'));
Fabio Rochaf0d95472019-05-28 21:35:19221 layersSection.addAlternateKeys(UI.ShortcutsScreen.LayersPanelShortcuts.ZoomIn, Common.UIString('Zoom in'));
222 layersSection.addAlternateKeys(UI.ShortcutsScreen.LayersPanelShortcuts.ZoomOut, Common.UIString('Zoom out'));
223 layersSection.addRelatedKeys(
Blink Reformat4c46d092018-04-07 15:32:37224 UI.ShortcutsScreen.LayersPanelShortcuts.Up.concat(UI.ShortcutsScreen.LayersPanelShortcuts.Down),
225 Common.UIString('Pan or rotate up/down'));
Fabio Rochaf0d95472019-05-28 21:35:19226 layersSection.addRelatedKeys(
Blink Reformat4c46d092018-04-07 15:32:37227 UI.ShortcutsScreen.LayersPanelShortcuts.Left.concat(UI.ShortcutsScreen.LayersPanelShortcuts.Right),
228 Common.UIString('Pan or rotate left/right'));
229 }
230
231 /**
232 * @param {string} name
233 * @return {!UI.ShortcutsSection}
234 */
235 section(name) {
236 let section = this._sections[name];
Tim van der Lippe1d6e57a2019-09-30 11:55:34237 if (!section) {
Blink Reformat4c46d092018-04-07 15:32:37238 this._sections[name] = section = new UI.ShortcutsSection(name);
Tim van der Lippe1d6e57a2019-09-30 11:55:34239 }
Blink Reformat4c46d092018-04-07 15:32:37240 return section;
241 }
242
243 /**
244 * @return {!UI.Widget}
245 */
246 createShortcutsTabView() {
247 const orderedSections = [];
Tim van der Lippe1d6e57a2019-09-30 11:55:34248 for (const section in this._sections) {
Blink Reformat4c46d092018-04-07 15:32:37249 orderedSections.push(this._sections[section]);
Tim van der Lippe1d6e57a2019-09-30 11:55:34250 }
Blink Reformat4c46d092018-04-07 15:32:37251 function compareSections(a, b) {
252 return a.order - b.order;
253 }
254 orderedSections.sort(compareSections);
255
256 const widget = new UI.Widget();
257
258 widget.element.className = 'settings-tab-container'; // Override
Chandani Shrestha83bd7c92019-06-11 21:21:59259 widget.element.createChild('header').createChild('h1').createTextChild(ls`Shortcuts`);
Blink Reformat4c46d092018-04-07 15:32:37260 const scrollPane = widget.element.createChild('div', 'settings-container-wrapper');
261 const container = scrollPane.createChild('div');
262 container.className = 'settings-content settings-container';
Tim van der Lippe1d6e57a2019-09-30 11:55:34263 for (let i = 0; i < orderedSections.length; ++i) {
Blink Reformat4c46d092018-04-07 15:32:37264 orderedSections[i].renderSection(container);
Tim van der Lippe1d6e57a2019-09-30 11:55:34265 }
Blink Reformat4c46d092018-04-07 15:32:37266
267 const note = scrollPane.createChild('p', 'settings-footnote');
268 note.appendChild(UI.createDocumentationLink(
269 'iterate/inspect-styles/shortcuts', Common.UIString('Full list of DevTools keyboard shortcuts and gestures')));
270
271 return widget;
272 }
273};
274
275/**
276 * We cannot initialize it here as localized strings are not loaded yet.
277 * @type {!UI.ShortcutsScreen}
278 */
279UI.shortcutsScreen;
280
281/**
282 * @unrestricted
283 */
284UI.ShortcutsSection = class {
285 /**
286 * @param {string} name
287 */
288 constructor(name) {
289 this.name = name;
290 this._lines = /** @type {!Array.<!{key: !Node, text: string}>} */ ([]);
291 this.order = ++UI.ShortcutsSection._sequenceNumber;
292 }
293
294 /**
295 * @param {!UI.KeyboardShortcut.Descriptor} key
296 * @param {string} description
297 */
298 addKey(key, description) {
299 this._addLine(this._renderKey(key), description);
300 }
301
302 /**
303 * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} keys
304 * @param {string} description
305 */
306 addRelatedKeys(keys, description) {
307 this._addLine(this._renderSequence(keys, '/'), description);
308 }
309
310 /**
311 * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} keys
312 * @param {string} description
313 */
314 addAlternateKeys(keys, description) {
315 this._addLine(this._renderSequence(keys, Common.UIString('or')), description);
316 }
317
318 /**
319 * @param {!Node} keyElement
320 * @param {string} description
321 */
322 _addLine(keyElement, description) {
323 this._lines.push({key: keyElement, text: description});
324 }
325
326 /**
327 * @param {!Element} container
328 */
329 renderSection(container) {
330 const parent = container.createChild('div', 'settings-block');
331
332 const headLine = parent.createChild('div', 'settings-line');
333 headLine.createChild('div', 'settings-key-cell');
334 headLine.createChild('div', 'settings-section-title settings-cell').textContent = this.name;
Amanda Baker11630de2019-07-12 02:54:33335 UI.ARIAUtils.markAsHeading(headLine, /* level */ 2);
Blink Reformat4c46d092018-04-07 15:32:37336
337 for (let i = 0; i < this._lines.length; ++i) {
338 const line = parent.createChild('div', 'settings-line');
339 const keyCell = line.createChild('div', 'settings-key-cell');
340 keyCell.appendChild(this._lines[i].key);
341 keyCell.appendChild(this._createSpan('settings-key-delimiter', ':'));
342 line.createChild('div', 'settings-cell').textContent = this._lines[i].text;
343 }
344 }
345
346 /**
347 * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} sequence
348 * @param {string} delimiter
349 * @return {!Node}
350 */
351 _renderSequence(sequence, delimiter) {
352 const delimiterSpan = this._createSpan('settings-key-delimiter', delimiter);
353 return this._joinNodes(sequence.map(this._renderKey.bind(this)), delimiterSpan);
354 }
355
356 /**
357 * @param {!UI.KeyboardShortcut.Descriptor} key
358 * @return {!Node}
359 */
360 _renderKey(key) {
361 const keyName = key.name;
362 const plus = this._createSpan('settings-combine-keys', '+');
363 return this._joinNodes(keyName.split(' + ').map(this._createSpan.bind(this, 'settings-key')), plus);
364 }
365
366 /**
367 * @param {string} className
368 * @param {string} textContent
369 * @return {!Element}
370 */
371 _createSpan(className, textContent) {
372 const node = createElement('span');
373 node.className = className;
374 node.textContent = textContent;
375 return node;
376 }
377
378 /**
379 * @param {!Array.<!Element>} nodes
380 * @param {!Element} delimiter
381 * @return {!Node}
382 */
383 _joinNodes(nodes, delimiter) {
384 const result = createDocumentFragment();
385 for (let i = 0; i < nodes.length; ++i) {
Tim van der Lippe1d6e57a2019-09-30 11:55:34386 if (i > 0) {
Blink Reformat4c46d092018-04-07 15:32:37387 result.appendChild(delimiter.cloneNode(true));
Tim van der Lippe1d6e57a2019-09-30 11:55:34388 }
Blink Reformat4c46d092018-04-07 15:32:37389 result.appendChild(nodes[i]);
390 }
391 return result;
392 }
393};
394
395UI.ShortcutsSection._sequenceNumber = 0;
396
397
398UI.ShortcutsScreen.ElementsPanelShortcuts = {
399 NavigateUp: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Up)],
400
401 NavigateDown: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Down)],
402
403 Expand: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Right)],
404
405 Collapse: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Left)],
406
407 EditAttribute: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Enter)],
408
Blink Reformat4c46d092018-04-07 15:32:37409 NextProperty: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Tab)],
410
411 PreviousProperty:
412 [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Tab, UI.KeyboardShortcut.Modifiers.Shift)],
413
414 IncrementValue: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Up)],
415
416 DecrementValue: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Down)],
417
418 IncrementBy10: [
419 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.PageUp),
420 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Up, UI.KeyboardShortcut.Modifiers.Shift)
421 ],
422
423 DecrementBy10: [
424 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.PageDown),
425 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Down, UI.KeyboardShortcut.Modifiers.Shift)
426 ],
427
428 IncrementBy100:
429 [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.PageUp, UI.KeyboardShortcut.Modifiers.Shift)],
430
431 DecrementBy100:
432 [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.PageDown, UI.KeyboardShortcut.Modifiers.Shift)],
433
434 IncrementBy01: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Up, UI.KeyboardShortcut.Modifiers.Alt)],
435
436 DecrementBy01: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Down, UI.KeyboardShortcut.Modifiers.Alt)]
437};
438
Fabio Rochaf0d95472019-05-28 21:35:19439UI.ShortcutsScreen.ConsolePanelShortcuts = {
440 AcceptSuggestion: [
441 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Tab),
442 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Right)
443 ],
444
445 ClearConsolePrompt: [UI.KeyboardShortcut.makeDescriptor('u', UI.KeyboardShortcut.Modifiers.Ctrl)],
446
447 ExecuteCommand: UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Enter),
448
449 NextPreviousLine: [
450 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Down),
451 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Up)
452 ],
453
454 NextPreviousCommand: [
455 UI.KeyboardShortcut.makeDescriptor('N', UI.KeyboardShortcut.Modifiers.Alt),
456 UI.KeyboardShortcut.makeDescriptor('P', UI.KeyboardShortcut.Modifiers.Alt)
457 ],
458};
459
Blink Reformat4c46d092018-04-07 15:32:37460UI.ShortcutsScreen.SourcesPanelShortcuts = {
461 SelectNextOccurrence: [UI.KeyboardShortcut.makeDescriptor('d', UI.KeyboardShortcut.Modifiers.CtrlOrMeta)],
462
463 SoftUndo: [UI.KeyboardShortcut.makeDescriptor('u', UI.KeyboardShortcut.Modifiers.CtrlOrMeta)],
464
465 GotoMatchingBracket: [UI.KeyboardShortcut.makeDescriptor('m', UI.KeyboardShortcut.Modifiers.Ctrl)],
466
467 ToggleAutocompletion:
468 [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Space, UI.KeyboardShortcut.Modifiers.Ctrl)],
469
470 IncreaseCSSUnitByOne:
471 [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Up, UI.KeyboardShortcut.Modifiers.Alt)],
472
473 DecreaseCSSUnitByOne:
474 [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Down, UI.KeyboardShortcut.Modifiers.Alt)],
475
476 IncreaseCSSUnitByTen:
477 [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.PageUp, UI.KeyboardShortcut.Modifiers.Alt)],
478
479 DecreaseCSSUnitByTen:
480 [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.PageDown, UI.KeyboardShortcut.Modifiers.Alt)],
481 EvaluateSelectionInConsole: [UI.KeyboardShortcut.makeDescriptor(
482 'e', UI.KeyboardShortcut.Modifiers.Shift | UI.KeyboardShortcut.Modifiers.Ctrl)],
483
484 AddSelectionToWatch: [UI.KeyboardShortcut.makeDescriptor(
485 'a', UI.KeyboardShortcut.Modifiers.Shift | UI.KeyboardShortcut.Modifiers.Ctrl)],
486
487 ToggleComment:
488 [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Slash, UI.KeyboardShortcut.Modifiers.CtrlOrMeta)],
489};
490
491UI.ShortcutsScreen.LayersPanelShortcuts = {
492 ResetView: [UI.KeyboardShortcut.makeDescriptor('0')],
493
494 PanMode: [UI.KeyboardShortcut.makeDescriptor('x')],
495
496 RotateMode: [UI.KeyboardShortcut.makeDescriptor('v')],
497
498 TogglePanRotate: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Shift)],
499
500 ZoomIn: [
501 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Plus, UI.KeyboardShortcut.Modifiers.Shift),
502 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.NumpadPlus)
503 ],
504
505 ZoomOut: [
506 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Minus, UI.KeyboardShortcut.Modifiers.Shift),
507 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.NumpadMinus)
508 ],
509
510 Up: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Up), UI.KeyboardShortcut.makeDescriptor('w')],
511
512 Down: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Down), UI.KeyboardShortcut.makeDescriptor('s')],
513
514 Left: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Left), UI.KeyboardShortcut.makeDescriptor('a')],
515
516 Right: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Right), UI.KeyboardShortcut.makeDescriptor('d')]
517};