blob: 372b100e8fd3a49265a3840ed34927d8247fbc8f [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
Paul Lewis17e384e2020-01-08 15:46:5131import * as Common from '../common/common.js';
Paul Lewis0fd43712020-01-08 17:07:3632import * as Host from '../host/host.js';
33
Paul Lewis9950e182019-12-16 16:06:0734import {KeyboardShortcut, Keys, Modifiers} from './KeyboardShortcut.js';
35import {createDocumentationLink} from './UIUtils.js';
36import {Widget} from './Widget.js';
37
Blink Reformat4c46d092018-04-07 15:32:3738/**
39 * @unrestricted
40 */
Paul Lewis9950e182019-12-16 16:06:0741export class ShortcutsScreen {
Blink Reformat4c46d092018-04-07 15:32:3742 constructor() {
Tim van der Lippe0830b3d2019-10-03 13:20:0743 /** @type {!Object.<string, !ShortcutsSection>} */
Blink Reformat4c46d092018-04-07 15:32:3744 this._sections = {};
45 }
46
47 static registerShortcuts() {
48 // Elements panel
Paul Lewis21533b02020-01-24 14:56:3449 const elementsSection = self.UI.shortcutsScreen.section(Common.UIString.UIString('Elements Panel'));
Blink Reformat4c46d092018-04-07 15:32:3750
Tim van der Lippe0830b3d2019-10-03 13:20:0751 const navigate = ElementsPanelShortcuts.NavigateUp.concat(ElementsPanelShortcuts.NavigateDown);
Paul Lewis17e384e2020-01-08 15:46:5152 elementsSection.addRelatedKeys(navigate, Common.UIString.UIString('Navigate elements'));
Blink Reformat4c46d092018-04-07 15:32:3753
Tim van der Lippe0830b3d2019-10-03 13:20:0754 const expandCollapse = ElementsPanelShortcuts.Expand.concat(ElementsPanelShortcuts.Collapse);
Paul Lewis17e384e2020-01-08 15:46:5155 elementsSection.addRelatedKeys(expandCollapse, Common.UIString.UIString('Expand/collapse'));
Blink Reformat4c46d092018-04-07 15:32:3756
Paul Lewis17e384e2020-01-08 15:46:5157 elementsSection.addAlternateKeys(ElementsPanelShortcuts.EditAttribute, Common.UIString.UIString('Edit attribute'));
Blink Reformat4c46d092018-04-07 15:32:3758 elementsSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:4059 self.UI.shortcutRegistry.shortcutDescriptorsForAction('elements.hide-element'),
Paul Lewis17e384e2020-01-08 15:46:5160 Common.UIString.UIString('Hide element'));
Blink Reformat4c46d092018-04-07 15:32:3761 elementsSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:4062 self.UI.shortcutRegistry.shortcutDescriptorsForAction('elements.edit-as-html'),
Paul Lewis17e384e2020-01-08 15:46:5163 Common.UIString.UIString('Toggle edit as HTML'));
Blink Reformat4c46d092018-04-07 15:32:3764
Fabio Rochaf0d95472019-05-28 21:35:1965 // Styles pane
Paul Lewis21533b02020-01-24 14:56:3466 const stylesPaneSection = self.UI.shortcutsScreen.section(Common.UIString.UIString('Styles Pane'));
Blink Reformat4c46d092018-04-07 15:32:3767
Tim van der Lippe0830b3d2019-10-03 13:20:0768 const nextPreviousProperty = ElementsPanelShortcuts.NextProperty.concat(ElementsPanelShortcuts.PreviousProperty);
Paul Lewis17e384e2020-01-08 15:46:5169 stylesPaneSection.addRelatedKeys(nextPreviousProperty, Common.UIString.UIString('Next/previous property'));
Blink Reformat4c46d092018-04-07 15:32:3770
Paul Lewis17e384e2020-01-08 15:46:5171 stylesPaneSection.addRelatedKeys(
72 ElementsPanelShortcuts.IncrementValue, Common.UIString.UIString('Increment value'));
73 stylesPaneSection.addRelatedKeys(
74 ElementsPanelShortcuts.DecrementValue, Common.UIString.UIString('Decrement value'));
Blink Reformat4c46d092018-04-07 15:32:3775
Paul Lewis17e384e2020-01-08 15:46:5176 stylesPaneSection.addAlternateKeys(
77 ElementsPanelShortcuts.IncrementBy10, Common.UIString.UIString('Increment by %f', 10));
78 stylesPaneSection.addAlternateKeys(
79 ElementsPanelShortcuts.DecrementBy10, Common.UIString.UIString('Decrement by %f', 10));
Blink Reformat4c46d092018-04-07 15:32:3780
Paul Lewis17e384e2020-01-08 15:46:5181 stylesPaneSection.addAlternateKeys(
82 ElementsPanelShortcuts.IncrementBy100, Common.UIString.UIString('Increment by %f', 100));
83 stylesPaneSection.addAlternateKeys(
84 ElementsPanelShortcuts.DecrementBy100, Common.UIString.UIString('Decrement by %f', 100));
Blink Reformat4c46d092018-04-07 15:32:3785
Paul Lewis17e384e2020-01-08 15:46:5186 stylesPaneSection.addAlternateKeys(
87 ElementsPanelShortcuts.IncrementBy01, Common.UIString.UIString('Increment by %f', 0.1));
88 stylesPaneSection.addAlternateKeys(
89 ElementsPanelShortcuts.DecrementBy01, Common.UIString.UIString('Decrement by %f', 0.1));
Blink Reformat4c46d092018-04-07 15:32:3790
Fabio Rochaf0d95472019-05-28 21:35:1991 // Console
Paul Lewis21533b02020-01-24 14:56:3492 const consoleSection = self.UI.shortcutsScreen.section(Common.UIString.UIString('Console'));
Blink Reformat4c46d092018-04-07 15:32:3793
Fabio Rochaf0d95472019-05-28 21:35:1994 consoleSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:4095 self.UI.shortcutRegistry.shortcutDescriptorsForAction('console.clear'),
96 Common.UIString.UIString('Clear console'));
Paul Lewis17e384e2020-01-08 15:46:5197 consoleSection.addRelatedKeys(
98 ConsolePanelShortcuts.AcceptSuggestion, Common.UIString.UIString('Accept suggestion'));
99 consoleSection.addAlternateKeys(
100 ConsolePanelShortcuts.ClearConsolePrompt, Common.UIString.UIString('Clear console prompt'));
101 consoleSection.addRelatedKeys(
102 ConsolePanelShortcuts.NextPreviousLine, Common.UIString.UIString('Next/previous line'));
Fabio Rochaf0d95472019-05-28 21:35:19103
Paul Lewis0fd43712020-01-08 17:07:36104 if (Host.Platform.isMac()) {
Fabio Rochaf0d95472019-05-28 21:35:19105 consoleSection.addRelatedKeys(
Paul Lewis17e384e2020-01-08 15:46:51106 ConsolePanelShortcuts.NextPreviousCommand, Common.UIString.UIString('Next/previous command'));
Fabio Rochaf0d95472019-05-28 21:35:19107 }
108
Paul Lewis17e384e2020-01-08 15:46:51109 consoleSection.addKey(ConsolePanelShortcuts.ExecuteCommand, Common.UIString.UIString('Execute command'));
Fabio Rochaf0d95472019-05-28 21:35:19110
111 // Debugger
Paul Lewis21533b02020-01-24 14:56:34112 const debuggerSection = self.UI.shortcutsScreen.section(Common.UIString.UIString('Debugger'));
Fabio Rochaf0d95472019-05-28 21:35:19113
114 debuggerSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40115 self.UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.toggle-pause'),
Paul Lewis17e384e2020-01-08 15:46:51116 Common.UIString.UIString('Pause/ Continue'));
Fabio Rochaf0d95472019-05-28 21:35:19117 debuggerSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40118 self.UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.step-over'),
119 Common.UIString.UIString('Step over'));
Fabio Rochaf0d95472019-05-28 21:35:19120 debuggerSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40121 self.UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.step-into'),
122 Common.UIString.UIString('Step into'));
Fabio Rochaf0d95472019-05-28 21:35:19123 debuggerSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40124 self.UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.step-out'),
125 Common.UIString.UIString('Step out'));
Blink Reformat4c46d092018-04-07 15:32:37126
127 const nextAndPrevFrameKeys =
Paul Lewis05eb37f2020-01-24 14:31:40128 self.UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.next-call-frame')
129 .concat(self.UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.previous-call-frame'));
Paul Lewis17e384e2020-01-08 15:46:51130 debuggerSection.addRelatedKeys(nextAndPrevFrameKeys, Common.UIString.UIString('Next/previous call frame'));
Blink Reformat4c46d092018-04-07 15:32:37131
Fabio Rochaf0d95472019-05-28 21:35:19132 debuggerSection.addAlternateKeys(
Paul Lewis17e384e2020-01-08 15:46:51133 SourcesPanelShortcuts.EvaluateSelectionInConsole, Common.UIString.UIString('Evaluate selection in console'));
Fabio Rochaf0d95472019-05-28 21:35:19134 debuggerSection.addAlternateKeys(
Paul Lewis17e384e2020-01-08 15:46:51135 SourcesPanelShortcuts.AddSelectionToWatch, Common.UIString.UIString('Add selection to watch'));
Fabio Rochaf0d95472019-05-28 21:35:19136 debuggerSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40137 self.UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.toggle-breakpoint'),
Paul Lewis17e384e2020-01-08 15:46:51138 Common.UIString.UIString('Toggle breakpoint'));
Fabio Rochaf0d95472019-05-28 21:35:19139 debuggerSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40140 self.UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.toggle-breakpoint-enabled'),
Paul Lewis17e384e2020-01-08 15:46:51141 Common.UIString.UIString('Toggle breakpoint enabled'));
Fabio Rochaf0d95472019-05-28 21:35:19142 debuggerSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40143 self.UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.toggle-breakpoints-active'),
Paul Lewis17e384e2020-01-08 15:46:51144 Common.UIString.UIString('Toggle all breakpoints'));
Olivia Flynn8e746e02019-06-19 17:06:23145 debuggerSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40146 self.UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.breakpoint-input-window'),
Olivia Flynn8e746e02019-06-19 17:06:23147 ls`Open breakpoint editor`);
Blink Reformat4c46d092018-04-07 15:32:37148
149 // Editing
Paul Lewis21533b02020-01-24 14:56:34150 const editingSection = self.UI.shortcutsScreen.section(Common.UIString.UIString('Text Editor'));
Fabio Rochaf0d95472019-05-28 21:35:19151
152 editingSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40153 self.UI.shortcutRegistry.shortcutDescriptorsForAction('sources.go-to-member'),
Paul Lewis17e384e2020-01-08 15:46:51154 Common.UIString.UIString('Go to member'));
Fabio Rochaf0d95472019-05-28 21:35:19155 editingSection.addAlternateKeys(
Paul Lewis17e384e2020-01-08 15:46:51156 SourcesPanelShortcuts.ToggleAutocompletion, Common.UIString.UIString('Autocompletion'));
157 editingSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40158 self.UI.shortcutRegistry.shortcutDescriptorsForAction('sources.go-to-line'),
159 Common.UIString.UIString('Go to line'));
Fabio Rochaf0d95472019-05-28 21:35:19160 editingSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40161 self.UI.shortcutRegistry.shortcutDescriptorsForAction('sources.jump-to-previous-location'),
Paul Lewis17e384e2020-01-08 15:46:51162 Common.UIString.UIString('Jump to previous editing location'));
Fabio Rochaf0d95472019-05-28 21:35:19163 editingSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40164 self.UI.shortcutRegistry.shortcutDescriptorsForAction('sources.jump-to-next-location'),
Paul Lewis17e384e2020-01-08 15:46:51165 Common.UIString.UIString('Jump to next editing location'));
166 editingSection.addAlternateKeys(SourcesPanelShortcuts.ToggleComment, Common.UIString.UIString('Toggle comment'));
Fabio Rochaf0d95472019-05-28 21:35:19167 editingSection.addAlternateKeys(
Paul Lewis17e384e2020-01-08 15:46:51168 SourcesPanelShortcuts.IncreaseCSSUnitByOne, Common.UIString.UIString('Increment CSS unit by 1'));
Fabio Rochaf0d95472019-05-28 21:35:19169 editingSection.addAlternateKeys(
Paul Lewis17e384e2020-01-08 15:46:51170 SourcesPanelShortcuts.DecreaseCSSUnitByOne, Common.UIString.UIString('Decrement CSS unit by 1'));
Fabio Rochaf0d95472019-05-28 21:35:19171 editingSection.addAlternateKeys(
Paul Lewis17e384e2020-01-08 15:46:51172 SourcesPanelShortcuts.IncreaseCSSUnitByTen, Common.UIString.UIString('Increment CSS unit by 10'));
Fabio Rochaf0d95472019-05-28 21:35:19173 editingSection.addAlternateKeys(
Paul Lewis17e384e2020-01-08 15:46:51174 SourcesPanelShortcuts.DecreaseCSSUnitByTen, Common.UIString.UIString('Decrement CSS unit by 10'));
Fabio Rochaf0d95472019-05-28 21:35:19175 editingSection.addAlternateKeys(
Paul Lewis17e384e2020-01-08 15:46:51176 SourcesPanelShortcuts.SelectNextOccurrence, Common.UIString.UIString('Select next occurrence'));
177 editingSection.addAlternateKeys(SourcesPanelShortcuts.SoftUndo, Common.UIString.UIString('Soft undo'));
Fabio Rochaf0d95472019-05-28 21:35:19178 editingSection.addAlternateKeys(
Paul Lewis17e384e2020-01-08 15:46:51179 SourcesPanelShortcuts.GotoMatchingBracket, Common.UIString.UIString('Go to matching bracket'));
Fabio Rochaf0d95472019-05-28 21:35:19180 editingSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40181 self.UI.shortcutRegistry.shortcutDescriptorsForAction('sources.close-editor-tab'),
Paul Lewis17e384e2020-01-08 15:46:51182 Common.UIString.UIString('Close editor tab'));
Fabio Rochaf0d95472019-05-28 21:35:19183 editingSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40184 self.UI.shortcutRegistry.shortcutDescriptorsForAction('sources.switch-file'),
Paul Lewis17e384e2020-01-08 15:46:51185 Common.UIString.UIString('Switch between files with the same name and different extensions.'));
Blink Reformat4c46d092018-04-07 15:32:37186
187 // Performance panel
Paul Lewis21533b02020-01-24 14:56:34188 const performanceSection = self.UI.shortcutsScreen.section(Common.UIString.UIString('Performance Panel'));
Fabio Rochaf0d95472019-05-28 21:35:19189
190 performanceSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40191 self.UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.toggle-recording'),
Paul Lewis17e384e2020-01-08 15:46:51192 Common.UIString.UIString('Start/stop recording'));
Fabio Rochaf0d95472019-05-28 21:35:19193 performanceSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40194 self.UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.record-reload'),
Paul Lewis17e384e2020-01-08 15:46:51195 Common.UIString.UIString('Record page reload'));
Fabio Rochaf0d95472019-05-28 21:35:19196 performanceSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40197 self.UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.save-to-file'),
Paul Lewis17e384e2020-01-08 15:46:51198 Common.UIString.UIString('Save profile'));
Fabio Rochaf0d95472019-05-28 21:35:19199 performanceSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40200 self.UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.load-from-file'),
Paul Lewis17e384e2020-01-08 15:46:51201 Common.UIString.UIString('Load profile'));
Fabio Rochaf0d95472019-05-28 21:35:19202 performanceSection.addRelatedKeys(
Paul Lewis05eb37f2020-01-24 14:31:40203 self.UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.jump-to-previous-frame')
204 .concat(self.UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.jump-to-next-frame')),
Paul Lewis17e384e2020-01-08 15:46:51205 Common.UIString.UIString('Jump to previous/next frame'));
Fabio Rochaf0d95472019-05-28 21:35:19206 performanceSection.addRelatedKeys(
Paul Lewis05eb37f2020-01-24 14:31:40207 self.UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.show-history'),
Paul Lewis17e384e2020-01-08 15:46:51208 Common.UIString.UIString('Pick a recording from history'));
Fabio Rochaf0d95472019-05-28 21:35:19209 performanceSection.addRelatedKeys(
Paul Lewis05eb37f2020-01-24 14:31:40210 self.UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.previous-recording')
211 .concat(self.UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.next-recording')),
Paul Lewis17e384e2020-01-08 15:46:51212 Common.UIString.UIString('Show previous/next recording'));
Blink Reformat4c46d092018-04-07 15:32:37213
214 // Memory panel
Paul Lewis21533b02020-01-24 14:56:34215 const memorySection = self.UI.shortcutsScreen.section(Common.UIString.UIString('Memory Panel'));
Fabio Rochaf0d95472019-05-28 21:35:19216
217 memorySection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40218 self.UI.shortcutRegistry.shortcutDescriptorsForAction('profiler.heap-toggle-recording'),
Paul Lewis17e384e2020-01-08 15:46:51219 Common.UIString.UIString('Start/stop recording'));
Blink Reformat4c46d092018-04-07 15:32:37220
221 // Layers panel
Paul Lewis21533b02020-01-24 14:56:34222 const layersSection = self.UI.shortcutsScreen.section(Common.UIString.UIString('Layers Panel'));
Fabio Rochaf0d95472019-05-28 21:35:19223
Paul Lewis17e384e2020-01-08 15:46:51224 layersSection.addAlternateKeys(LayersPanelShortcuts.ResetView, Common.UIString.UIString('Reset view'));
225 layersSection.addAlternateKeys(LayersPanelShortcuts.PanMode, Common.UIString.UIString('Switch to pan mode'));
226 layersSection.addAlternateKeys(LayersPanelShortcuts.RotateMode, Common.UIString.UIString('Switch to rotate mode'));
Fabio Rochaf0d95472019-05-28 21:35:19227 layersSection.addAlternateKeys(
Paul Lewis17e384e2020-01-08 15:46:51228 LayersPanelShortcuts.TogglePanRotate,
229 Common.UIString.UIString('Temporarily toggle pan/rotate mode while held'));
230 layersSection.addAlternateKeys(LayersPanelShortcuts.ZoomIn, Common.UIString.UIString('Zoom in'));
231 layersSection.addAlternateKeys(LayersPanelShortcuts.ZoomOut, Common.UIString.UIString('Zoom out'));
Fabio Rochaf0d95472019-05-28 21:35:19232 layersSection.addRelatedKeys(
Paul Lewis17e384e2020-01-08 15:46:51233 LayersPanelShortcuts.Up.concat(LayersPanelShortcuts.Down), Common.UIString.UIString('Pan or rotate up/down'));
Fabio Rochaf0d95472019-05-28 21:35:19234 layersSection.addRelatedKeys(
Paul Lewis17e384e2020-01-08 15:46:51235 LayersPanelShortcuts.Left.concat(LayersPanelShortcuts.Right),
236 Common.UIString.UIString('Pan or rotate left/right'));
Blink Reformat4c46d092018-04-07 15:32:37237 }
238
239 /**
240 * @param {string} name
Tim van der Lippe0830b3d2019-10-03 13:20:07241 * @return {!ShortcutsSection}
Blink Reformat4c46d092018-04-07 15:32:37242 */
243 section(name) {
244 let section = this._sections[name];
Tim van der Lippe1d6e57a2019-09-30 11:55:34245 if (!section) {
Tim van der Lippe0830b3d2019-10-03 13:20:07246 this._sections[name] = section = new ShortcutsSection(name);
Tim van der Lippe1d6e57a2019-09-30 11:55:34247 }
Blink Reformat4c46d092018-04-07 15:32:37248 return section;
249 }
250
251 /**
Paul Lewis9950e182019-12-16 16:06:07252 * @return {!Widget}
Blink Reformat4c46d092018-04-07 15:32:37253 */
254 createShortcutsTabView() {
255 const orderedSections = [];
Tim van der Lippe1d6e57a2019-09-30 11:55:34256 for (const section in this._sections) {
Blink Reformat4c46d092018-04-07 15:32:37257 orderedSections.push(this._sections[section]);
Tim van der Lippe1d6e57a2019-09-30 11:55:34258 }
Blink Reformat4c46d092018-04-07 15:32:37259 function compareSections(a, b) {
260 return a.order - b.order;
261 }
262 orderedSections.sort(compareSections);
263
Paul Lewis9950e182019-12-16 16:06:07264 const widget = new Widget();
Blink Reformat4c46d092018-04-07 15:32:37265
266 widget.element.className = 'settings-tab-container'; // Override
Chandani Shrestha83bd7c92019-06-11 21:21:59267 widget.element.createChild('header').createChild('h1').createTextChild(ls`Shortcuts`);
Blink Reformat4c46d092018-04-07 15:32:37268 const scrollPane = widget.element.createChild('div', 'settings-container-wrapper');
269 const container = scrollPane.createChild('div');
270 container.className = 'settings-content settings-container';
Tim van der Lippe1d6e57a2019-09-30 11:55:34271 for (let i = 0; i < orderedSections.length; ++i) {
Blink Reformat4c46d092018-04-07 15:32:37272 orderedSections[i].renderSection(container);
Tim van der Lippe1d6e57a2019-09-30 11:55:34273 }
Blink Reformat4c46d092018-04-07 15:32:37274
275 const note = scrollPane.createChild('p', 'settings-footnote');
Paul Lewis9950e182019-12-16 16:06:07276 note.appendChild(createDocumentationLink(
Paul Lewis17e384e2020-01-08 15:46:51277 'iterate/inspect-styles/shortcuts',
278 Common.UIString.UIString('Full list of DevTools keyboard shortcuts and gestures')));
Blink Reformat4c46d092018-04-07 15:32:37279
280 return widget;
281 }
Tim van der Lippe0830b3d2019-10-03 13:20:07282}
Blink Reformat4c46d092018-04-07 15:32:37283
284/**
Blink Reformat4c46d092018-04-07 15:32:37285 * @unrestricted
286 */
Tim van der Lippec96ccd92019-11-29 16:23:54287class ShortcutsSection {
Blink Reformat4c46d092018-04-07 15:32:37288 /**
289 * @param {string} name
290 */
291 constructor(name) {
292 this.name = name;
293 this._lines = /** @type {!Array.<!{key: !Node, text: string}>} */ ([]);
Tim van der Lippe0830b3d2019-10-03 13:20:07294 this.order = ++ShortcutsSection._sequenceNumber;
Blink Reformat4c46d092018-04-07 15:32:37295 }
296
297 /**
298 * @param {!UI.KeyboardShortcut.Descriptor} key
299 * @param {string} description
300 */
301 addKey(key, description) {
302 this._addLine(this._renderKey(key), description);
303 }
304
305 /**
306 * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} keys
307 * @param {string} description
308 */
309 addRelatedKeys(keys, description) {
310 this._addLine(this._renderSequence(keys, '/'), description);
311 }
312
313 /**
314 * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} keys
315 * @param {string} description
316 */
317 addAlternateKeys(keys, description) {
Paul Lewis17e384e2020-01-08 15:46:51318 this._addLine(this._renderSequence(keys, Common.UIString.UIString('or')), description);
Blink Reformat4c46d092018-04-07 15:32:37319 }
320
321 /**
322 * @param {!Node} keyElement
323 * @param {string} description
324 */
325 _addLine(keyElement, description) {
326 this._lines.push({key: keyElement, text: description});
327 }
328
329 /**
330 * @param {!Element} container
331 */
332 renderSection(container) {
333 const parent = container.createChild('div', 'settings-block');
334
335 const headLine = parent.createChild('div', 'settings-line');
336 headLine.createChild('div', 'settings-key-cell');
337 headLine.createChild('div', 'settings-section-title settings-cell').textContent = this.name;
Amanda Baker11630de2019-07-12 02:54:33338 UI.ARIAUtils.markAsHeading(headLine, /* level */ 2);
Blink Reformat4c46d092018-04-07 15:32:37339
340 for (let i = 0; i < this._lines.length; ++i) {
341 const line = parent.createChild('div', 'settings-line');
342 const keyCell = line.createChild('div', 'settings-key-cell');
343 keyCell.appendChild(this._lines[i].key);
344 keyCell.appendChild(this._createSpan('settings-key-delimiter', ':'));
345 line.createChild('div', 'settings-cell').textContent = this._lines[i].text;
346 }
347 }
348
349 /**
350 * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} sequence
351 * @param {string} delimiter
352 * @return {!Node}
353 */
354 _renderSequence(sequence, delimiter) {
355 const delimiterSpan = this._createSpan('settings-key-delimiter', delimiter);
356 return this._joinNodes(sequence.map(this._renderKey.bind(this)), delimiterSpan);
357 }
358
359 /**
360 * @param {!UI.KeyboardShortcut.Descriptor} key
361 * @return {!Node}
362 */
363 _renderKey(key) {
364 const keyName = key.name;
365 const plus = this._createSpan('settings-combine-keys', '+');
366 return this._joinNodes(keyName.split(' + ').map(this._createSpan.bind(this, 'settings-key')), plus);
367 }
368
369 /**
370 * @param {string} className
371 * @param {string} textContent
372 * @return {!Element}
373 */
374 _createSpan(className, textContent) {
375 const node = createElement('span');
376 node.className = className;
377 node.textContent = textContent;
378 return node;
379 }
380
381 /**
382 * @param {!Array.<!Element>} nodes
383 * @param {!Element} delimiter
384 * @return {!Node}
385 */
386 _joinNodes(nodes, delimiter) {
387 const result = createDocumentFragment();
388 for (let i = 0; i < nodes.length; ++i) {
Tim van der Lippe1d6e57a2019-09-30 11:55:34389 if (i > 0) {
Blink Reformat4c46d092018-04-07 15:32:37390 result.appendChild(delimiter.cloneNode(true));
Tim van der Lippe1d6e57a2019-09-30 11:55:34391 }
Blink Reformat4c46d092018-04-07 15:32:37392 result.appendChild(nodes[i]);
393 }
394 return result;
395 }
Tim van der Lippe0830b3d2019-10-03 13:20:07396}
Blink Reformat4c46d092018-04-07 15:32:37397
Tim van der Lippe0830b3d2019-10-03 13:20:07398ShortcutsSection._sequenceNumber = 0;
Blink Reformat4c46d092018-04-07 15:32:37399
400
Tim van der Lippec96ccd92019-11-29 16:23:54401const ElementsPanelShortcuts = {
Paul Lewis9950e182019-12-16 16:06:07402 NavigateUp: [KeyboardShortcut.makeDescriptor(Keys.Up)],
Blink Reformat4c46d092018-04-07 15:32:37403
Paul Lewis9950e182019-12-16 16:06:07404 NavigateDown: [KeyboardShortcut.makeDescriptor(Keys.Down)],
Blink Reformat4c46d092018-04-07 15:32:37405
Paul Lewis9950e182019-12-16 16:06:07406 Expand: [KeyboardShortcut.makeDescriptor(Keys.Right)],
Blink Reformat4c46d092018-04-07 15:32:37407
Paul Lewis9950e182019-12-16 16:06:07408 Collapse: [KeyboardShortcut.makeDescriptor(Keys.Left)],
Blink Reformat4c46d092018-04-07 15:32:37409
Paul Lewis9950e182019-12-16 16:06:07410 EditAttribute: [KeyboardShortcut.makeDescriptor(Keys.Enter)],
Blink Reformat4c46d092018-04-07 15:32:37411
Paul Lewis9950e182019-12-16 16:06:07412 NextProperty: [KeyboardShortcut.makeDescriptor(Keys.Tab)],
Blink Reformat4c46d092018-04-07 15:32:37413
Paul Lewis9950e182019-12-16 16:06:07414 PreviousProperty: [KeyboardShortcut.makeDescriptor(Keys.Tab, Modifiers.Shift)],
Blink Reformat4c46d092018-04-07 15:32:37415
Paul Lewis9950e182019-12-16 16:06:07416 IncrementValue: [KeyboardShortcut.makeDescriptor(Keys.Up)],
Blink Reformat4c46d092018-04-07 15:32:37417
Paul Lewis9950e182019-12-16 16:06:07418 DecrementValue: [KeyboardShortcut.makeDescriptor(Keys.Down)],
Blink Reformat4c46d092018-04-07 15:32:37419
Paul Lewis9950e182019-12-16 16:06:07420 IncrementBy10:
421 [KeyboardShortcut.makeDescriptor(Keys.PageUp), KeyboardShortcut.makeDescriptor(Keys.Up, Modifiers.Shift)],
Blink Reformat4c46d092018-04-07 15:32:37422
Paul Lewis9950e182019-12-16 16:06:07423 DecrementBy10:
424 [KeyboardShortcut.makeDescriptor(Keys.PageDown), KeyboardShortcut.makeDescriptor(Keys.Down, Modifiers.Shift)],
Blink Reformat4c46d092018-04-07 15:32:37425
Paul Lewis9950e182019-12-16 16:06:07426 IncrementBy100: [KeyboardShortcut.makeDescriptor(Keys.PageUp, Modifiers.Shift)],
Blink Reformat4c46d092018-04-07 15:32:37427
Paul Lewis9950e182019-12-16 16:06:07428 DecrementBy100: [KeyboardShortcut.makeDescriptor(Keys.PageDown, Modifiers.Shift)],
Blink Reformat4c46d092018-04-07 15:32:37429
Paul Lewis9950e182019-12-16 16:06:07430 IncrementBy01: [KeyboardShortcut.makeDescriptor(Keys.Up, Modifiers.Alt)],
Blink Reformat4c46d092018-04-07 15:32:37431
Paul Lewis9950e182019-12-16 16:06:07432 DecrementBy01: [KeyboardShortcut.makeDescriptor(Keys.Down, Modifiers.Alt)]
Blink Reformat4c46d092018-04-07 15:32:37433};
434
Tim van der Lippec96ccd92019-11-29 16:23:54435const ConsolePanelShortcuts = {
Paul Lewis9950e182019-12-16 16:06:07436 AcceptSuggestion: [KeyboardShortcut.makeDescriptor(Keys.Tab), KeyboardShortcut.makeDescriptor(Keys.Right)],
Fabio Rochaf0d95472019-05-28 21:35:19437
Paul Lewis9950e182019-12-16 16:06:07438 ClearConsolePrompt: [KeyboardShortcut.makeDescriptor('u', Modifiers.Ctrl)],
Fabio Rochaf0d95472019-05-28 21:35:19439
Paul Lewis9950e182019-12-16 16:06:07440 ExecuteCommand: KeyboardShortcut.makeDescriptor(Keys.Enter),
Fabio Rochaf0d95472019-05-28 21:35:19441
Paul Lewis9950e182019-12-16 16:06:07442 NextPreviousLine: [KeyboardShortcut.makeDescriptor(Keys.Down), KeyboardShortcut.makeDescriptor(Keys.Up)],
Fabio Rochaf0d95472019-05-28 21:35:19443
Paul Lewis9950e182019-12-16 16:06:07444 NextPreviousCommand:
445 [KeyboardShortcut.makeDescriptor('N', Modifiers.Alt), KeyboardShortcut.makeDescriptor('P', Modifiers.Alt)],
Fabio Rochaf0d95472019-05-28 21:35:19446};
447
Tim van der Lippe0830b3d2019-10-03 13:20:07448export const SourcesPanelShortcuts = {
Paul Lewis9950e182019-12-16 16:06:07449 SelectNextOccurrence: [KeyboardShortcut.makeDescriptor('d', Modifiers.CtrlOrMeta)],
Blink Reformat4c46d092018-04-07 15:32:37450
Paul Lewis9950e182019-12-16 16:06:07451 SoftUndo: [KeyboardShortcut.makeDescriptor('u', Modifiers.CtrlOrMeta)],
Blink Reformat4c46d092018-04-07 15:32:37452
Paul Lewis9950e182019-12-16 16:06:07453 GotoMatchingBracket: [KeyboardShortcut.makeDescriptor('m', Modifiers.Ctrl)],
Blink Reformat4c46d092018-04-07 15:32:37454
Paul Lewis9950e182019-12-16 16:06:07455 ToggleAutocompletion: [KeyboardShortcut.makeDescriptor(Keys.Space, Modifiers.Ctrl)],
Blink Reformat4c46d092018-04-07 15:32:37456
Paul Lewis9950e182019-12-16 16:06:07457 IncreaseCSSUnitByOne: [KeyboardShortcut.makeDescriptor(Keys.Up, Modifiers.Alt)],
Blink Reformat4c46d092018-04-07 15:32:37458
Paul Lewis9950e182019-12-16 16:06:07459 DecreaseCSSUnitByOne: [KeyboardShortcut.makeDescriptor(Keys.Down, Modifiers.Alt)],
Blink Reformat4c46d092018-04-07 15:32:37460
Paul Lewis9950e182019-12-16 16:06:07461 IncreaseCSSUnitByTen: [KeyboardShortcut.makeDescriptor(Keys.PageUp, Modifiers.Alt)],
Blink Reformat4c46d092018-04-07 15:32:37462
Paul Lewis9950e182019-12-16 16:06:07463 DecreaseCSSUnitByTen: [KeyboardShortcut.makeDescriptor(Keys.PageDown, Modifiers.Alt)],
464 EvaluateSelectionInConsole: [KeyboardShortcut.makeDescriptor('e', Modifiers.Shift | Modifiers.Ctrl)],
Blink Reformat4c46d092018-04-07 15:32:37465
Paul Lewis9950e182019-12-16 16:06:07466 AddSelectionToWatch: [KeyboardShortcut.makeDescriptor('a', Modifiers.Shift | Modifiers.Ctrl)],
Blink Reformat4c46d092018-04-07 15:32:37467
Paul Lewis9950e182019-12-16 16:06:07468 ToggleComment: [KeyboardShortcut.makeDescriptor(Keys.Slash, Modifiers.CtrlOrMeta)],
Blink Reformat4c46d092018-04-07 15:32:37469};
470
Tim van der Lippe0830b3d2019-10-03 13:20:07471export const LayersPanelShortcuts = {
Paul Lewis9950e182019-12-16 16:06:07472 ResetView: [KeyboardShortcut.makeDescriptor('0')],
Blink Reformat4c46d092018-04-07 15:32:37473
Paul Lewis9950e182019-12-16 16:06:07474 PanMode: [KeyboardShortcut.makeDescriptor('x')],
Blink Reformat4c46d092018-04-07 15:32:37475
Paul Lewis9950e182019-12-16 16:06:07476 RotateMode: [KeyboardShortcut.makeDescriptor('v')],
Blink Reformat4c46d092018-04-07 15:32:37477
Paul Lewis9950e182019-12-16 16:06:07478 TogglePanRotate: [KeyboardShortcut.makeDescriptor(Keys.Shift)],
Blink Reformat4c46d092018-04-07 15:32:37479
Paul Lewis9950e182019-12-16 16:06:07480 ZoomIn:
481 [KeyboardShortcut.makeDescriptor(Keys.Plus, Modifiers.Shift), KeyboardShortcut.makeDescriptor(Keys.NumpadPlus)],
Blink Reformat4c46d092018-04-07 15:32:37482
Paul Lewis9950e182019-12-16 16:06:07483 ZoomOut:
484 [KeyboardShortcut.makeDescriptor(Keys.Minus, Modifiers.Shift), KeyboardShortcut.makeDescriptor(Keys.NumpadMinus)],
Blink Reformat4c46d092018-04-07 15:32:37485
Paul Lewis9950e182019-12-16 16:06:07486 Up: [KeyboardShortcut.makeDescriptor(Keys.Up), KeyboardShortcut.makeDescriptor('w')],
Blink Reformat4c46d092018-04-07 15:32:37487
Paul Lewis9950e182019-12-16 16:06:07488 Down: [KeyboardShortcut.makeDescriptor(Keys.Down), KeyboardShortcut.makeDescriptor('s')],
Blink Reformat4c46d092018-04-07 15:32:37489
Paul Lewis9950e182019-12-16 16:06:07490 Left: [KeyboardShortcut.makeDescriptor(Keys.Left), KeyboardShortcut.makeDescriptor('a')],
Blink Reformat4c46d092018-04-07 15:32:37491
Paul Lewis9950e182019-12-16 16:06:07492 Right: [KeyboardShortcut.makeDescriptor(Keys.Right), KeyboardShortcut.makeDescriptor('d')]
Blink Reformat4c46d092018-04-07 15:32:37493};