blob: 02bef2240f8fd613149e513ceecc53b65bde8e5c [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 */
Tim van der Lippe0830b3d2019-10-03 13:20:0734export default class ShortcutsScreen {
Blink Reformat4c46d092018-04-07 15:32:3735 constructor() {
Tim van der Lippe0830b3d2019-10-03 13:20:0736 /** @type {!Object.<string, !ShortcutsSection>} */
Blink Reformat4c46d092018-04-07 15:32:3737 this._sections = {};
38 }
39
40 static registerShortcuts() {
41 // Elements panel
42 const elementsSection = UI.shortcutsScreen.section(Common.UIString('Elements Panel'));
43
Tim van der Lippe0830b3d2019-10-03 13:20:0744 const navigate = ElementsPanelShortcuts.NavigateUp.concat(ElementsPanelShortcuts.NavigateDown);
Blink Reformat4c46d092018-04-07 15:32:3745 elementsSection.addRelatedKeys(navigate, Common.UIString('Navigate elements'));
46
Tim van der Lippe0830b3d2019-10-03 13:20:0747 const expandCollapse = ElementsPanelShortcuts.Expand.concat(ElementsPanelShortcuts.Collapse);
Blink Reformat4c46d092018-04-07 15:32:3748 elementsSection.addRelatedKeys(expandCollapse, Common.UIString('Expand/collapse'));
49
Tim van der Lippe0830b3d2019-10-03 13:20:0750 elementsSection.addAlternateKeys(ElementsPanelShortcuts.EditAttribute, Common.UIString('Edit attribute'));
Blink Reformat4c46d092018-04-07 15:32:3751 elementsSection.addAlternateKeys(
Joel Einbindera66e5bf2018-05-31 01:26:3752 UI.shortcutRegistry.shortcutDescriptorsForAction('elements.hide-element'), Common.UIString('Hide element'));
Blink Reformat4c46d092018-04-07 15:32:3753 elementsSection.addAlternateKeys(
Joel Einbindera66e5bf2018-05-31 01:26:3754 UI.shortcutRegistry.shortcutDescriptorsForAction('elements.edit-as-html'),
55 Common.UIString('Toggle edit as HTML'));
Blink Reformat4c46d092018-04-07 15:32:3756
Fabio Rochaf0d95472019-05-28 21:35:1957 // Styles pane
Blink Reformat4c46d092018-04-07 15:32:3758 const stylesPaneSection = UI.shortcutsScreen.section(Common.UIString('Styles Pane'));
59
Tim van der Lippe0830b3d2019-10-03 13:20:0760 const nextPreviousProperty = ElementsPanelShortcuts.NextProperty.concat(ElementsPanelShortcuts.PreviousProperty);
Blink Reformat4c46d092018-04-07 15:32:3761 stylesPaneSection.addRelatedKeys(nextPreviousProperty, Common.UIString('Next/previous property'));
62
Tim van der Lippe0830b3d2019-10-03 13:20:0763 stylesPaneSection.addRelatedKeys(ElementsPanelShortcuts.IncrementValue, Common.UIString('Increment value'));
64 stylesPaneSection.addRelatedKeys(ElementsPanelShortcuts.DecrementValue, Common.UIString('Decrement value'));
Blink Reformat4c46d092018-04-07 15:32:3765
Tim van der Lippe0830b3d2019-10-03 13:20:0766 stylesPaneSection.addAlternateKeys(ElementsPanelShortcuts.IncrementBy10, Common.UIString('Increment by %f', 10));
67 stylesPaneSection.addAlternateKeys(ElementsPanelShortcuts.DecrementBy10, Common.UIString('Decrement by %f', 10));
Blink Reformat4c46d092018-04-07 15:32:3768
Tim van der Lippe0830b3d2019-10-03 13:20:0769 stylesPaneSection.addAlternateKeys(ElementsPanelShortcuts.IncrementBy100, Common.UIString('Increment by %f', 100));
70 stylesPaneSection.addAlternateKeys(ElementsPanelShortcuts.DecrementBy100, Common.UIString('Decrement by %f', 100));
Blink Reformat4c46d092018-04-07 15:32:3771
Tim van der Lippe0830b3d2019-10-03 13:20:0772 stylesPaneSection.addAlternateKeys(ElementsPanelShortcuts.IncrementBy01, Common.UIString('Increment by %f', 0.1));
73 stylesPaneSection.addAlternateKeys(ElementsPanelShortcuts.DecrementBy01, Common.UIString('Decrement by %f', 0.1));
Blink Reformat4c46d092018-04-07 15:32:3774
Fabio Rochaf0d95472019-05-28 21:35:1975 // Console
76 const consoleSection = UI.shortcutsScreen.section(Common.UIString('Console'));
Blink Reformat4c46d092018-04-07 15:32:3777
Fabio Rochaf0d95472019-05-28 21:35:1978 consoleSection.addAlternateKeys(
79 UI.shortcutRegistry.shortcutDescriptorsForAction('console.clear'), Common.UIString('Clear console'));
Tim van der Lippe0830b3d2019-10-03 13:20:0780 consoleSection.addRelatedKeys(ConsolePanelShortcuts.AcceptSuggestion, Common.UIString('Accept suggestion'));
81 consoleSection.addAlternateKeys(ConsolePanelShortcuts.ClearConsolePrompt, Common.UIString('Clear console prompt'));
82 consoleSection.addRelatedKeys(ConsolePanelShortcuts.NextPreviousLine, Common.UIString('Next/previous line'));
Fabio Rochaf0d95472019-05-28 21:35:1983
84 if (Host.isMac()) {
85 consoleSection.addRelatedKeys(
Tim van der Lippe0830b3d2019-10-03 13:20:0786 ConsolePanelShortcuts.NextPreviousCommand, Common.UIString('Next/previous command'));
Fabio Rochaf0d95472019-05-28 21:35:1987 }
88
Tim van der Lippe0830b3d2019-10-03 13:20:0789 consoleSection.addKey(ConsolePanelShortcuts.ExecuteCommand, Common.UIString('Execute command'));
Fabio Rochaf0d95472019-05-28 21:35:1990
91 // Debugger
92 const debuggerSection = UI.shortcutsScreen.section(Common.UIString('Debugger'));
93
94 debuggerSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:3795 UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.toggle-pause'), Common.UIString('Pause/ Continue'));
Fabio Rochaf0d95472019-05-28 21:35:1996 debuggerSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:3797 UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.step-over'), Common.UIString('Step over'));
Fabio Rochaf0d95472019-05-28 21:35:1998 debuggerSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:3799 UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.step-into'), Common.UIString('Step into'));
Fabio Rochaf0d95472019-05-28 21:35:19100 debuggerSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37101 UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.step-out'), Common.UIString('Step out'));
102
103 const nextAndPrevFrameKeys =
104 UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.next-call-frame')
105 .concat(UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.previous-call-frame'));
Fabio Rochaf0d95472019-05-28 21:35:19106 debuggerSection.addRelatedKeys(nextAndPrevFrameKeys, Common.UIString('Next/previous call frame'));
Blink Reformat4c46d092018-04-07 15:32:37107
Fabio Rochaf0d95472019-05-28 21:35:19108 debuggerSection.addAlternateKeys(
Tim van der Lippe0830b3d2019-10-03 13:20:07109 SourcesPanelShortcuts.EvaluateSelectionInConsole, Common.UIString('Evaluate selection in console'));
Fabio Rochaf0d95472019-05-28 21:35:19110 debuggerSection.addAlternateKeys(
Tim van der Lippe0830b3d2019-10-03 13:20:07111 SourcesPanelShortcuts.AddSelectionToWatch, Common.UIString('Add selection to watch'));
Fabio Rochaf0d95472019-05-28 21:35:19112 debuggerSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37113 UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.toggle-breakpoint'),
114 Common.UIString('Toggle breakpoint'));
Fabio Rochaf0d95472019-05-28 21:35:19115 debuggerSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37116 UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.toggle-breakpoint-enabled'),
117 Common.UIString('Toggle breakpoint enabled'));
Fabio Rochaf0d95472019-05-28 21:35:19118 debuggerSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37119 UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.toggle-breakpoints-active'),
120 Common.UIString('Toggle all breakpoints'));
Olivia Flynn8e746e02019-06-19 17:06:23121 debuggerSection.addAlternateKeys(
122 UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.breakpoint-input-window'),
123 ls`Open breakpoint editor`);
Blink Reformat4c46d092018-04-07 15:32:37124
125 // Editing
Fabio Rochaf0d95472019-05-28 21:35:19126 const editingSection = UI.shortcutsScreen.section(Common.UIString('Text Editor'));
127
128 editingSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37129 UI.shortcutRegistry.shortcutDescriptorsForAction('sources.go-to-member'), Common.UIString('Go to member'));
Tim van der Lippe0830b3d2019-10-03 13:20:07130 editingSection.addAlternateKeys(SourcesPanelShortcuts.ToggleAutocompletion, Common.UIString('Autocompletion'));
Fabio Rochaf0d95472019-05-28 21:35:19131 editingSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37132 UI.shortcutRegistry.shortcutDescriptorsForAction('sources.go-to-line'), Common.UIString('Go to line'));
Fabio Rochaf0d95472019-05-28 21:35:19133 editingSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37134 UI.shortcutRegistry.shortcutDescriptorsForAction('sources.jump-to-previous-location'),
135 Common.UIString('Jump to previous editing location'));
Fabio Rochaf0d95472019-05-28 21:35:19136 editingSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37137 UI.shortcutRegistry.shortcutDescriptorsForAction('sources.jump-to-next-location'),
138 Common.UIString('Jump to next editing location'));
Tim van der Lippe0830b3d2019-10-03 13:20:07139 editingSection.addAlternateKeys(SourcesPanelShortcuts.ToggleComment, Common.UIString('Toggle comment'));
Fabio Rochaf0d95472019-05-28 21:35:19140 editingSection.addAlternateKeys(
Tim van der Lippe0830b3d2019-10-03 13:20:07141 SourcesPanelShortcuts.IncreaseCSSUnitByOne, Common.UIString('Increment CSS unit by 1'));
Fabio Rochaf0d95472019-05-28 21:35:19142 editingSection.addAlternateKeys(
Tim van der Lippe0830b3d2019-10-03 13:20:07143 SourcesPanelShortcuts.DecreaseCSSUnitByOne, Common.UIString('Decrement CSS unit by 1'));
Fabio Rochaf0d95472019-05-28 21:35:19144 editingSection.addAlternateKeys(
Tim van der Lippe0830b3d2019-10-03 13:20:07145 SourcesPanelShortcuts.IncreaseCSSUnitByTen, Common.UIString('Increment CSS unit by 10'));
Fabio Rochaf0d95472019-05-28 21:35:19146 editingSection.addAlternateKeys(
Tim van der Lippe0830b3d2019-10-03 13:20:07147 SourcesPanelShortcuts.DecreaseCSSUnitByTen, Common.UIString('Decrement CSS unit by 10'));
Fabio Rochaf0d95472019-05-28 21:35:19148 editingSection.addAlternateKeys(
Tim van der Lippe0830b3d2019-10-03 13:20:07149 SourcesPanelShortcuts.SelectNextOccurrence, Common.UIString('Select next occurrence'));
150 editingSection.addAlternateKeys(SourcesPanelShortcuts.SoftUndo, Common.UIString('Soft undo'));
Fabio Rochaf0d95472019-05-28 21:35:19151 editingSection.addAlternateKeys(
Tim van der Lippe0830b3d2019-10-03 13:20:07152 SourcesPanelShortcuts.GotoMatchingBracket, Common.UIString('Go to matching bracket'));
Fabio Rochaf0d95472019-05-28 21:35:19153 editingSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37154 UI.shortcutRegistry.shortcutDescriptorsForAction('sources.close-editor-tab'),
155 Common.UIString('Close editor tab'));
Fabio Rochaf0d95472019-05-28 21:35:19156 editingSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37157 UI.shortcutRegistry.shortcutDescriptorsForAction('sources.switch-file'),
158 Common.UIString('Switch between files with the same name and different extensions.'));
159
160 // Performance panel
Fabio Rochaf0d95472019-05-28 21:35:19161 const performanceSection = UI.shortcutsScreen.section(Common.UIString('Performance Panel'));
162
163 performanceSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37164 UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.toggle-recording'),
165 Common.UIString('Start/stop recording'));
Fabio Rochaf0d95472019-05-28 21:35:19166 performanceSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37167 UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.record-reload'),
168 Common.UIString('Record page reload'));
Fabio Rochaf0d95472019-05-28 21:35:19169 performanceSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37170 UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.save-to-file'), Common.UIString('Save profile'));
Fabio Rochaf0d95472019-05-28 21:35:19171 performanceSection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37172 UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.load-from-file'), Common.UIString('Load profile'));
Fabio Rochaf0d95472019-05-28 21:35:19173 performanceSection.addRelatedKeys(
Blink Reformat4c46d092018-04-07 15:32:37174 UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.jump-to-previous-frame')
175 .concat(UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.jump-to-next-frame')),
176 Common.UIString('Jump to previous/next frame'));
Fabio Rochaf0d95472019-05-28 21:35:19177 performanceSection.addRelatedKeys(
Blink Reformat4c46d092018-04-07 15:32:37178 UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.show-history'),
179 Common.UIString('Pick a recording from history'));
Fabio Rochaf0d95472019-05-28 21:35:19180 performanceSection.addRelatedKeys(
Blink Reformat4c46d092018-04-07 15:32:37181 UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.previous-recording')
182 .concat(UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.next-recording')),
183 Common.UIString('Show previous/next recording'));
184
185 // Memory panel
Fabio Rochaf0d95472019-05-28 21:35:19186 const memorySection = UI.shortcutsScreen.section(Common.UIString('Memory Panel'));
187
188 memorySection.addAlternateKeys(
Blink Reformat4c46d092018-04-07 15:32:37189 UI.shortcutRegistry.shortcutDescriptorsForAction('profiler.heap-toggle-recording'),
190 Common.UIString('Start/stop recording'));
191
192 // Layers panel
Fabio Rochaf0d95472019-05-28 21:35:19193 const layersSection = UI.shortcutsScreen.section(Common.UIString('Layers Panel'));
194
Tim van der Lippe0830b3d2019-10-03 13:20:07195 layersSection.addAlternateKeys(LayersPanelShortcuts.ResetView, Common.UIString('Reset view'));
196 layersSection.addAlternateKeys(LayersPanelShortcuts.PanMode, Common.UIString('Switch to pan mode'));
197 layersSection.addAlternateKeys(LayersPanelShortcuts.RotateMode, Common.UIString('Switch to rotate mode'));
Fabio Rochaf0d95472019-05-28 21:35:19198 layersSection.addAlternateKeys(
Tim van der Lippe0830b3d2019-10-03 13:20:07199 LayersPanelShortcuts.TogglePanRotate, Common.UIString('Temporarily toggle pan/rotate mode while held'));
200 layersSection.addAlternateKeys(LayersPanelShortcuts.ZoomIn, Common.UIString('Zoom in'));
201 layersSection.addAlternateKeys(LayersPanelShortcuts.ZoomOut, Common.UIString('Zoom out'));
Fabio Rochaf0d95472019-05-28 21:35:19202 layersSection.addRelatedKeys(
Tim van der Lippe0830b3d2019-10-03 13:20:07203 LayersPanelShortcuts.Up.concat(LayersPanelShortcuts.Down), Common.UIString('Pan or rotate up/down'));
Fabio Rochaf0d95472019-05-28 21:35:19204 layersSection.addRelatedKeys(
Tim van der Lippe0830b3d2019-10-03 13:20:07205 LayersPanelShortcuts.Left.concat(LayersPanelShortcuts.Right), Common.UIString('Pan or rotate left/right'));
Blink Reformat4c46d092018-04-07 15:32:37206 }
207
208 /**
209 * @param {string} name
Tim van der Lippe0830b3d2019-10-03 13:20:07210 * @return {!ShortcutsSection}
Blink Reformat4c46d092018-04-07 15:32:37211 */
212 section(name) {
213 let section = this._sections[name];
Tim van der Lippe1d6e57a2019-09-30 11:55:34214 if (!section) {
Tim van der Lippe0830b3d2019-10-03 13:20:07215 this._sections[name] = section = new ShortcutsSection(name);
Tim van der Lippe1d6e57a2019-09-30 11:55:34216 }
Blink Reformat4c46d092018-04-07 15:32:37217 return section;
218 }
219
220 /**
221 * @return {!UI.Widget}
222 */
223 createShortcutsTabView() {
224 const orderedSections = [];
Tim van der Lippe1d6e57a2019-09-30 11:55:34225 for (const section in this._sections) {
Blink Reformat4c46d092018-04-07 15:32:37226 orderedSections.push(this._sections[section]);
Tim van der Lippe1d6e57a2019-09-30 11:55:34227 }
Blink Reformat4c46d092018-04-07 15:32:37228 function compareSections(a, b) {
229 return a.order - b.order;
230 }
231 orderedSections.sort(compareSections);
232
233 const widget = new UI.Widget();
234
235 widget.element.className = 'settings-tab-container'; // Override
Chandani Shrestha83bd7c92019-06-11 21:21:59236 widget.element.createChild('header').createChild('h1').createTextChild(ls`Shortcuts`);
Blink Reformat4c46d092018-04-07 15:32:37237 const scrollPane = widget.element.createChild('div', 'settings-container-wrapper');
238 const container = scrollPane.createChild('div');
239 container.className = 'settings-content settings-container';
Tim van der Lippe1d6e57a2019-09-30 11:55:34240 for (let i = 0; i < orderedSections.length; ++i) {
Blink Reformat4c46d092018-04-07 15:32:37241 orderedSections[i].renderSection(container);
Tim van der Lippe1d6e57a2019-09-30 11:55:34242 }
Blink Reformat4c46d092018-04-07 15:32:37243
244 const note = scrollPane.createChild('p', 'settings-footnote');
245 note.appendChild(UI.createDocumentationLink(
246 'iterate/inspect-styles/shortcuts', Common.UIString('Full list of DevTools keyboard shortcuts and gestures')));
247
248 return widget;
249 }
Tim van der Lippe0830b3d2019-10-03 13:20:07250}
Blink Reformat4c46d092018-04-07 15:32:37251
252/**
253 * We cannot initialize it here as localized strings are not loaded yet.
Tim van der Lippe0830b3d2019-10-03 13:20:07254 * @type {!ShortcutsScreen}
Blink Reformat4c46d092018-04-07 15:32:37255 */
256UI.shortcutsScreen;
257
258/**
259 * @unrestricted
260 */
Tim van der Lippe0830b3d2019-10-03 13:20:07261export class ShortcutsSection {
Blink Reformat4c46d092018-04-07 15:32:37262 /**
263 * @param {string} name
264 */
265 constructor(name) {
266 this.name = name;
267 this._lines = /** @type {!Array.<!{key: !Node, text: string}>} */ ([]);
Tim van der Lippe0830b3d2019-10-03 13:20:07268 this.order = ++ShortcutsSection._sequenceNumber;
Blink Reformat4c46d092018-04-07 15:32:37269 }
270
271 /**
272 * @param {!UI.KeyboardShortcut.Descriptor} key
273 * @param {string} description
274 */
275 addKey(key, description) {
276 this._addLine(this._renderKey(key), description);
277 }
278
279 /**
280 * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} keys
281 * @param {string} description
282 */
283 addRelatedKeys(keys, description) {
284 this._addLine(this._renderSequence(keys, '/'), description);
285 }
286
287 /**
288 * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} keys
289 * @param {string} description
290 */
291 addAlternateKeys(keys, description) {
292 this._addLine(this._renderSequence(keys, Common.UIString('or')), description);
293 }
294
295 /**
296 * @param {!Node} keyElement
297 * @param {string} description
298 */
299 _addLine(keyElement, description) {
300 this._lines.push({key: keyElement, text: description});
301 }
302
303 /**
304 * @param {!Element} container
305 */
306 renderSection(container) {
307 const parent = container.createChild('div', 'settings-block');
308
309 const headLine = parent.createChild('div', 'settings-line');
310 headLine.createChild('div', 'settings-key-cell');
311 headLine.createChild('div', 'settings-section-title settings-cell').textContent = this.name;
Amanda Baker11630de2019-07-12 02:54:33312 UI.ARIAUtils.markAsHeading(headLine, /* level */ 2);
Blink Reformat4c46d092018-04-07 15:32:37313
314 for (let i = 0; i < this._lines.length; ++i) {
315 const line = parent.createChild('div', 'settings-line');
316 const keyCell = line.createChild('div', 'settings-key-cell');
317 keyCell.appendChild(this._lines[i].key);
318 keyCell.appendChild(this._createSpan('settings-key-delimiter', ':'));
319 line.createChild('div', 'settings-cell').textContent = this._lines[i].text;
320 }
321 }
322
323 /**
324 * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} sequence
325 * @param {string} delimiter
326 * @return {!Node}
327 */
328 _renderSequence(sequence, delimiter) {
329 const delimiterSpan = this._createSpan('settings-key-delimiter', delimiter);
330 return this._joinNodes(sequence.map(this._renderKey.bind(this)), delimiterSpan);
331 }
332
333 /**
334 * @param {!UI.KeyboardShortcut.Descriptor} key
335 * @return {!Node}
336 */
337 _renderKey(key) {
338 const keyName = key.name;
339 const plus = this._createSpan('settings-combine-keys', '+');
340 return this._joinNodes(keyName.split(' + ').map(this._createSpan.bind(this, 'settings-key')), plus);
341 }
342
343 /**
344 * @param {string} className
345 * @param {string} textContent
346 * @return {!Element}
347 */
348 _createSpan(className, textContent) {
349 const node = createElement('span');
350 node.className = className;
351 node.textContent = textContent;
352 return node;
353 }
354
355 /**
356 * @param {!Array.<!Element>} nodes
357 * @param {!Element} delimiter
358 * @return {!Node}
359 */
360 _joinNodes(nodes, delimiter) {
361 const result = createDocumentFragment();
362 for (let i = 0; i < nodes.length; ++i) {
Tim van der Lippe1d6e57a2019-09-30 11:55:34363 if (i > 0) {
Blink Reformat4c46d092018-04-07 15:32:37364 result.appendChild(delimiter.cloneNode(true));
Tim van der Lippe1d6e57a2019-09-30 11:55:34365 }
Blink Reformat4c46d092018-04-07 15:32:37366 result.appendChild(nodes[i]);
367 }
368 return result;
369 }
Tim van der Lippe0830b3d2019-10-03 13:20:07370}
Blink Reformat4c46d092018-04-07 15:32:37371
Tim van der Lippe0830b3d2019-10-03 13:20:07372ShortcutsSection._sequenceNumber = 0;
Blink Reformat4c46d092018-04-07 15:32:37373
374
Tim van der Lippe0830b3d2019-10-03 13:20:07375export const ElementsPanelShortcuts = {
Blink Reformat4c46d092018-04-07 15:32:37376 NavigateUp: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Up)],
377
378 NavigateDown: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Down)],
379
380 Expand: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Right)],
381
382 Collapse: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Left)],
383
384 EditAttribute: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Enter)],
385
Blink Reformat4c46d092018-04-07 15:32:37386 NextProperty: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Tab)],
387
388 PreviousProperty:
389 [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Tab, UI.KeyboardShortcut.Modifiers.Shift)],
390
391 IncrementValue: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Up)],
392
393 DecrementValue: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Down)],
394
395 IncrementBy10: [
396 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.PageUp),
397 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Up, UI.KeyboardShortcut.Modifiers.Shift)
398 ],
399
400 DecrementBy10: [
401 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.PageDown),
402 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Down, UI.KeyboardShortcut.Modifiers.Shift)
403 ],
404
405 IncrementBy100:
406 [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.PageUp, UI.KeyboardShortcut.Modifiers.Shift)],
407
408 DecrementBy100:
409 [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.PageDown, UI.KeyboardShortcut.Modifiers.Shift)],
410
411 IncrementBy01: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Up, UI.KeyboardShortcut.Modifiers.Alt)],
412
413 DecrementBy01: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Down, UI.KeyboardShortcut.Modifiers.Alt)]
414};
415
Tim van der Lippe0830b3d2019-10-03 13:20:07416export const ConsolePanelShortcuts = {
Fabio Rochaf0d95472019-05-28 21:35:19417 AcceptSuggestion: [
418 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Tab),
419 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Right)
420 ],
421
422 ClearConsolePrompt: [UI.KeyboardShortcut.makeDescriptor('u', UI.KeyboardShortcut.Modifiers.Ctrl)],
423
424 ExecuteCommand: UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Enter),
425
426 NextPreviousLine: [
427 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Down),
428 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Up)
429 ],
430
431 NextPreviousCommand: [
432 UI.KeyboardShortcut.makeDescriptor('N', UI.KeyboardShortcut.Modifiers.Alt),
433 UI.KeyboardShortcut.makeDescriptor('P', UI.KeyboardShortcut.Modifiers.Alt)
434 ],
435};
436
Tim van der Lippe0830b3d2019-10-03 13:20:07437export const SourcesPanelShortcuts = {
Blink Reformat4c46d092018-04-07 15:32:37438 SelectNextOccurrence: [UI.KeyboardShortcut.makeDescriptor('d', UI.KeyboardShortcut.Modifiers.CtrlOrMeta)],
439
440 SoftUndo: [UI.KeyboardShortcut.makeDescriptor('u', UI.KeyboardShortcut.Modifiers.CtrlOrMeta)],
441
442 GotoMatchingBracket: [UI.KeyboardShortcut.makeDescriptor('m', UI.KeyboardShortcut.Modifiers.Ctrl)],
443
444 ToggleAutocompletion:
445 [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Space, UI.KeyboardShortcut.Modifiers.Ctrl)],
446
447 IncreaseCSSUnitByOne:
448 [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Up, UI.KeyboardShortcut.Modifiers.Alt)],
449
450 DecreaseCSSUnitByOne:
451 [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Down, UI.KeyboardShortcut.Modifiers.Alt)],
452
453 IncreaseCSSUnitByTen:
454 [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.PageUp, UI.KeyboardShortcut.Modifiers.Alt)],
455
456 DecreaseCSSUnitByTen:
457 [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.PageDown, UI.KeyboardShortcut.Modifiers.Alt)],
458 EvaluateSelectionInConsole: [UI.KeyboardShortcut.makeDescriptor(
459 'e', UI.KeyboardShortcut.Modifiers.Shift | UI.KeyboardShortcut.Modifiers.Ctrl)],
460
461 AddSelectionToWatch: [UI.KeyboardShortcut.makeDescriptor(
462 'a', UI.KeyboardShortcut.Modifiers.Shift | UI.KeyboardShortcut.Modifiers.Ctrl)],
463
464 ToggleComment:
465 [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Slash, UI.KeyboardShortcut.Modifiers.CtrlOrMeta)],
466};
467
Tim van der Lippe0830b3d2019-10-03 13:20:07468export const LayersPanelShortcuts = {
Blink Reformat4c46d092018-04-07 15:32:37469 ResetView: [UI.KeyboardShortcut.makeDescriptor('0')],
470
471 PanMode: [UI.KeyboardShortcut.makeDescriptor('x')],
472
473 RotateMode: [UI.KeyboardShortcut.makeDescriptor('v')],
474
475 TogglePanRotate: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Shift)],
476
477 ZoomIn: [
478 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Plus, UI.KeyboardShortcut.Modifiers.Shift),
479 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.NumpadPlus)
480 ],
481
482 ZoomOut: [
483 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Minus, UI.KeyboardShortcut.Modifiers.Shift),
484 UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.NumpadMinus)
485 ],
486
487 Up: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Up), UI.KeyboardShortcut.makeDescriptor('w')],
488
489 Down: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Down), UI.KeyboardShortcut.makeDescriptor('s')],
490
491 Left: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Left), UI.KeyboardShortcut.makeDescriptor('a')],
492
493 Right: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Right), UI.KeyboardShortcut.makeDescriptor('d')]
494};
Tim van der Lippe0830b3d2019-10-03 13:20:07495
496/* Legacy exported object*/
497self.UI = self.UI || {};
498
499/* Legacy exported object*/
500UI = UI || {};
501
502/** @constructor */
503UI.ShortcutsScreen = ShortcutsScreen;
504
505/** @constructor */
506UI.ShortcutsSection = ShortcutsSection;
507
508UI.ShortcutsScreen.ElementsPanelShortcuts = ElementsPanelShortcuts;
509UI.ShortcutsScreen.ConsolePanelShortcuts = ConsolePanelShortcuts;
510UI.ShortcutsScreen.SourcesPanelShortcuts = SourcesPanelShortcuts;
511UI.ShortcutsScreen.LayersPanelShortcuts = LayersPanelShortcuts;