Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 34 | UI.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 Einbinder | a66e5bf | 2018-05-31 01:26:37 | [diff] [blame] | 55 | UI.shortcutRegistry.shortcutDescriptorsForAction('elements.hide-element'), Common.UIString('Hide element')); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 56 | elementsSection.addAlternateKeys( |
Joel Einbinder | a66e5bf | 2018-05-31 01:26:37 | [diff] [blame] | 57 | UI.shortcutRegistry.shortcutDescriptorsForAction('elements.edit-as-html'), |
| 58 | Common.UIString('Toggle edit as HTML')); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 59 | |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 60 | // Styles pane |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 61 | 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 Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 87 | // Console |
| 88 | const consoleSection = UI.shortcutsScreen.section(Common.UIString('Console')); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 89 | |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 90 | 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 Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 110 | UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.toggle-pause'), Common.UIString('Pause/ Continue')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 111 | debuggerSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 112 | UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.step-over'), Common.UIString('Step over')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 113 | debuggerSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 114 | UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.step-into'), Common.UIString('Step into')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 115 | debuggerSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 116 | 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 Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 121 | debuggerSection.addRelatedKeys(nextAndPrevFrameKeys, Common.UIString('Next/previous call frame')); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 122 | |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 123 | debuggerSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 124 | UI.ShortcutsScreen.SourcesPanelShortcuts.EvaluateSelectionInConsole, |
| 125 | Common.UIString('Evaluate selection in console')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 126 | debuggerSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 127 | UI.ShortcutsScreen.SourcesPanelShortcuts.AddSelectionToWatch, Common.UIString('Add selection to watch')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 128 | debuggerSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 129 | UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.toggle-breakpoint'), |
| 130 | Common.UIString('Toggle breakpoint')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 131 | debuggerSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 132 | UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.toggle-breakpoint-enabled'), |
| 133 | Common.UIString('Toggle breakpoint enabled')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 134 | debuggerSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 135 | UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.toggle-breakpoints-active'), |
| 136 | Common.UIString('Toggle all breakpoints')); |
| 137 | |
| 138 | // Editing |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 139 | const editingSection = UI.shortcutsScreen.section(Common.UIString('Text Editor')); |
| 140 | |
| 141 | editingSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 142 | UI.shortcutRegistry.shortcutDescriptorsForAction('sources.go-to-member'), Common.UIString('Go to member')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 143 | editingSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 144 | UI.ShortcutsScreen.SourcesPanelShortcuts.ToggleAutocompletion, Common.UIString('Autocompletion')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 145 | editingSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 146 | UI.shortcutRegistry.shortcutDescriptorsForAction('sources.go-to-line'), Common.UIString('Go to line')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 147 | editingSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 148 | UI.shortcutRegistry.shortcutDescriptorsForAction('sources.jump-to-previous-location'), |
| 149 | Common.UIString('Jump to previous editing location')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 150 | editingSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 151 | UI.shortcutRegistry.shortcutDescriptorsForAction('sources.jump-to-next-location'), |
| 152 | Common.UIString('Jump to next editing location')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 153 | editingSection.addAlternateKeys( |
| 154 | UI.ShortcutsScreen.SourcesPanelShortcuts.ToggleComment, Common.UIString('Toggle comment')); |
| 155 | editingSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 156 | UI.ShortcutsScreen.SourcesPanelShortcuts.IncreaseCSSUnitByOne, Common.UIString('Increment CSS unit by 1')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 157 | editingSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 158 | UI.ShortcutsScreen.SourcesPanelShortcuts.DecreaseCSSUnitByOne, Common.UIString('Decrement CSS unit by 1')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 159 | editingSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 160 | UI.ShortcutsScreen.SourcesPanelShortcuts.IncreaseCSSUnitByTen, Common.UIString('Increment CSS unit by 10')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 161 | editingSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 162 | UI.ShortcutsScreen.SourcesPanelShortcuts.DecreaseCSSUnitByTen, Common.UIString('Decrement CSS unit by 10')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 163 | editingSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 164 | UI.ShortcutsScreen.SourcesPanelShortcuts.SelectNextOccurrence, Common.UIString('Select next occurrence')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 165 | editingSection.addAlternateKeys(UI.ShortcutsScreen.SourcesPanelShortcuts.SoftUndo, Common.UIString('Soft undo')); |
| 166 | editingSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 167 | UI.ShortcutsScreen.SourcesPanelShortcuts.GotoMatchingBracket, Common.UIString('Go to matching bracket')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 168 | editingSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 169 | UI.shortcutRegistry.shortcutDescriptorsForAction('sources.close-editor-tab'), |
| 170 | Common.UIString('Close editor tab')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 171 | editingSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 172 | UI.shortcutRegistry.shortcutDescriptorsForAction('sources.switch-file'), |
| 173 | Common.UIString('Switch between files with the same name and different extensions.')); |
| 174 | |
| 175 | // Performance panel |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 176 | const performanceSection = UI.shortcutsScreen.section(Common.UIString('Performance Panel')); |
| 177 | |
| 178 | performanceSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 179 | UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.toggle-recording'), |
| 180 | Common.UIString('Start/stop recording')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 181 | performanceSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 182 | UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.record-reload'), |
| 183 | Common.UIString('Record page reload')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 184 | performanceSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 185 | UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.save-to-file'), Common.UIString('Save profile')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 186 | performanceSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 187 | UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.load-from-file'), Common.UIString('Load profile')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 188 | performanceSection.addRelatedKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 189 | UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.jump-to-previous-frame') |
| 190 | .concat(UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.jump-to-next-frame')), |
| 191 | Common.UIString('Jump to previous/next frame')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 192 | performanceSection.addRelatedKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 193 | UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.show-history'), |
| 194 | Common.UIString('Pick a recording from history')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 195 | performanceSection.addRelatedKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 196 | UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.previous-recording') |
| 197 | .concat(UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.next-recording')), |
| 198 | Common.UIString('Show previous/next recording')); |
| 199 | |
| 200 | // Memory panel |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 201 | const memorySection = UI.shortcutsScreen.section(Common.UIString('Memory Panel')); |
| 202 | |
| 203 | memorySection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 204 | UI.shortcutRegistry.shortcutDescriptorsForAction('profiler.heap-toggle-recording'), |
| 205 | Common.UIString('Start/stop recording')); |
| 206 | |
| 207 | // Layers panel |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 208 | const layersSection = UI.shortcutsScreen.section(Common.UIString('Layers Panel')); |
| 209 | |
| 210 | layersSection.addAlternateKeys(UI.ShortcutsScreen.LayersPanelShortcuts.ResetView, Common.UIString('Reset view')); |
| 211 | layersSection.addAlternateKeys( |
| 212 | UI.ShortcutsScreen.LayersPanelShortcuts.PanMode, Common.UIString('Switch to pan mode')); |
| 213 | layersSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 214 | UI.ShortcutsScreen.LayersPanelShortcuts.RotateMode, Common.UIString('Switch to rotate mode')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 215 | layersSection.addAlternateKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 216 | UI.ShortcutsScreen.LayersPanelShortcuts.TogglePanRotate, |
| 217 | Common.UIString('Temporarily toggle pan/rotate mode while held')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 218 | layersSection.addAlternateKeys(UI.ShortcutsScreen.LayersPanelShortcuts.ZoomIn, Common.UIString('Zoom in')); |
| 219 | layersSection.addAlternateKeys(UI.ShortcutsScreen.LayersPanelShortcuts.ZoomOut, Common.UIString('Zoom out')); |
| 220 | layersSection.addRelatedKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 221 | UI.ShortcutsScreen.LayersPanelShortcuts.Up.concat(UI.ShortcutsScreen.LayersPanelShortcuts.Down), |
| 222 | Common.UIString('Pan or rotate up/down')); |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 223 | layersSection.addRelatedKeys( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 224 | UI.ShortcutsScreen.LayersPanelShortcuts.Left.concat(UI.ShortcutsScreen.LayersPanelShortcuts.Right), |
| 225 | Common.UIString('Pan or rotate left/right')); |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * @param {string} name |
| 230 | * @return {!UI.ShortcutsSection} |
| 231 | */ |
| 232 | section(name) { |
| 233 | let section = this._sections[name]; |
| 234 | if (!section) |
| 235 | this._sections[name] = section = new UI.ShortcutsSection(name); |
| 236 | return section; |
| 237 | } |
| 238 | |
| 239 | /** |
| 240 | * @return {!UI.Widget} |
| 241 | */ |
| 242 | createShortcutsTabView() { |
| 243 | const orderedSections = []; |
| 244 | for (const section in this._sections) |
| 245 | orderedSections.push(this._sections[section]); |
| 246 | function compareSections(a, b) { |
| 247 | return a.order - b.order; |
| 248 | } |
| 249 | orderedSections.sort(compareSections); |
| 250 | |
| 251 | const widget = new UI.Widget(); |
| 252 | |
| 253 | widget.element.className = 'settings-tab-container'; // Override |
Chandani Shrestha | 83bd7c9 | 2019-06-11 21:21:59 | [diff] [blame^] | 254 | widget.element.createChild('header').createChild('h1').createTextChild(ls`Shortcuts`); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 255 | const scrollPane = widget.element.createChild('div', 'settings-container-wrapper'); |
| 256 | const container = scrollPane.createChild('div'); |
| 257 | container.className = 'settings-content settings-container'; |
| 258 | for (let i = 0; i < orderedSections.length; ++i) |
| 259 | orderedSections[i].renderSection(container); |
| 260 | |
| 261 | const note = scrollPane.createChild('p', 'settings-footnote'); |
| 262 | note.appendChild(UI.createDocumentationLink( |
| 263 | 'iterate/inspect-styles/shortcuts', Common.UIString('Full list of DevTools keyboard shortcuts and gestures'))); |
| 264 | |
| 265 | return widget; |
| 266 | } |
| 267 | }; |
| 268 | |
| 269 | /** |
| 270 | * We cannot initialize it here as localized strings are not loaded yet. |
| 271 | * @type {!UI.ShortcutsScreen} |
| 272 | */ |
| 273 | UI.shortcutsScreen; |
| 274 | |
| 275 | /** |
| 276 | * @unrestricted |
| 277 | */ |
| 278 | UI.ShortcutsSection = class { |
| 279 | /** |
| 280 | * @param {string} name |
| 281 | */ |
| 282 | constructor(name) { |
| 283 | this.name = name; |
| 284 | this._lines = /** @type {!Array.<!{key: !Node, text: string}>} */ ([]); |
| 285 | this.order = ++UI.ShortcutsSection._sequenceNumber; |
| 286 | } |
| 287 | |
| 288 | /** |
| 289 | * @param {!UI.KeyboardShortcut.Descriptor} key |
| 290 | * @param {string} description |
| 291 | */ |
| 292 | addKey(key, description) { |
| 293 | this._addLine(this._renderKey(key), description); |
| 294 | } |
| 295 | |
| 296 | /** |
| 297 | * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} keys |
| 298 | * @param {string} description |
| 299 | */ |
| 300 | addRelatedKeys(keys, description) { |
| 301 | this._addLine(this._renderSequence(keys, '/'), description); |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} keys |
| 306 | * @param {string} description |
| 307 | */ |
| 308 | addAlternateKeys(keys, description) { |
| 309 | this._addLine(this._renderSequence(keys, Common.UIString('or')), description); |
| 310 | } |
| 311 | |
| 312 | /** |
| 313 | * @param {!Node} keyElement |
| 314 | * @param {string} description |
| 315 | */ |
| 316 | _addLine(keyElement, description) { |
| 317 | this._lines.push({key: keyElement, text: description}); |
| 318 | } |
| 319 | |
| 320 | /** |
| 321 | * @param {!Element} container |
| 322 | */ |
| 323 | renderSection(container) { |
| 324 | const parent = container.createChild('div', 'settings-block'); |
| 325 | |
| 326 | const headLine = parent.createChild('div', 'settings-line'); |
| 327 | headLine.createChild('div', 'settings-key-cell'); |
| 328 | headLine.createChild('div', 'settings-section-title settings-cell').textContent = this.name; |
| 329 | |
| 330 | for (let i = 0; i < this._lines.length; ++i) { |
| 331 | const line = parent.createChild('div', 'settings-line'); |
| 332 | const keyCell = line.createChild('div', 'settings-key-cell'); |
| 333 | keyCell.appendChild(this._lines[i].key); |
| 334 | keyCell.appendChild(this._createSpan('settings-key-delimiter', ':')); |
| 335 | line.createChild('div', 'settings-cell').textContent = this._lines[i].text; |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | /** |
| 340 | * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} sequence |
| 341 | * @param {string} delimiter |
| 342 | * @return {!Node} |
| 343 | */ |
| 344 | _renderSequence(sequence, delimiter) { |
| 345 | const delimiterSpan = this._createSpan('settings-key-delimiter', delimiter); |
| 346 | return this._joinNodes(sequence.map(this._renderKey.bind(this)), delimiterSpan); |
| 347 | } |
| 348 | |
| 349 | /** |
| 350 | * @param {!UI.KeyboardShortcut.Descriptor} key |
| 351 | * @return {!Node} |
| 352 | */ |
| 353 | _renderKey(key) { |
| 354 | const keyName = key.name; |
| 355 | const plus = this._createSpan('settings-combine-keys', '+'); |
| 356 | return this._joinNodes(keyName.split(' + ').map(this._createSpan.bind(this, 'settings-key')), plus); |
| 357 | } |
| 358 | |
| 359 | /** |
| 360 | * @param {string} className |
| 361 | * @param {string} textContent |
| 362 | * @return {!Element} |
| 363 | */ |
| 364 | _createSpan(className, textContent) { |
| 365 | const node = createElement('span'); |
| 366 | node.className = className; |
| 367 | node.textContent = textContent; |
| 368 | return node; |
| 369 | } |
| 370 | |
| 371 | /** |
| 372 | * @param {!Array.<!Element>} nodes |
| 373 | * @param {!Element} delimiter |
| 374 | * @return {!Node} |
| 375 | */ |
| 376 | _joinNodes(nodes, delimiter) { |
| 377 | const result = createDocumentFragment(); |
| 378 | for (let i = 0; i < nodes.length; ++i) { |
| 379 | if (i > 0) |
| 380 | result.appendChild(delimiter.cloneNode(true)); |
| 381 | result.appendChild(nodes[i]); |
| 382 | } |
| 383 | return result; |
| 384 | } |
| 385 | }; |
| 386 | |
| 387 | UI.ShortcutsSection._sequenceNumber = 0; |
| 388 | |
| 389 | |
| 390 | UI.ShortcutsScreen.ElementsPanelShortcuts = { |
| 391 | NavigateUp: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Up)], |
| 392 | |
| 393 | NavigateDown: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Down)], |
| 394 | |
| 395 | Expand: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Right)], |
| 396 | |
| 397 | Collapse: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Left)], |
| 398 | |
| 399 | EditAttribute: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Enter)], |
| 400 | |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 401 | NextProperty: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Tab)], |
| 402 | |
| 403 | PreviousProperty: |
| 404 | [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Tab, UI.KeyboardShortcut.Modifiers.Shift)], |
| 405 | |
| 406 | IncrementValue: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Up)], |
| 407 | |
| 408 | DecrementValue: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Down)], |
| 409 | |
| 410 | IncrementBy10: [ |
| 411 | UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.PageUp), |
| 412 | UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Up, UI.KeyboardShortcut.Modifiers.Shift) |
| 413 | ], |
| 414 | |
| 415 | DecrementBy10: [ |
| 416 | UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.PageDown), |
| 417 | UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Down, UI.KeyboardShortcut.Modifiers.Shift) |
| 418 | ], |
| 419 | |
| 420 | IncrementBy100: |
| 421 | [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.PageUp, UI.KeyboardShortcut.Modifiers.Shift)], |
| 422 | |
| 423 | DecrementBy100: |
| 424 | [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.PageDown, UI.KeyboardShortcut.Modifiers.Shift)], |
| 425 | |
| 426 | IncrementBy01: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Up, UI.KeyboardShortcut.Modifiers.Alt)], |
| 427 | |
| 428 | DecrementBy01: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Down, UI.KeyboardShortcut.Modifiers.Alt)] |
| 429 | }; |
| 430 | |
Fabio Rocha | f0d9547 | 2019-05-28 21:35:19 | [diff] [blame] | 431 | UI.ShortcutsScreen.ConsolePanelShortcuts = { |
| 432 | AcceptSuggestion: [ |
| 433 | UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Tab), |
| 434 | UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Right) |
| 435 | ], |
| 436 | |
| 437 | ClearConsolePrompt: [UI.KeyboardShortcut.makeDescriptor('u', UI.KeyboardShortcut.Modifiers.Ctrl)], |
| 438 | |
| 439 | ExecuteCommand: UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Enter), |
| 440 | |
| 441 | NextPreviousLine: [ |
| 442 | UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Down), |
| 443 | UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Up) |
| 444 | ], |
| 445 | |
| 446 | NextPreviousCommand: [ |
| 447 | UI.KeyboardShortcut.makeDescriptor('N', UI.KeyboardShortcut.Modifiers.Alt), |
| 448 | UI.KeyboardShortcut.makeDescriptor('P', UI.KeyboardShortcut.Modifiers.Alt) |
| 449 | ], |
| 450 | }; |
| 451 | |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 452 | UI.ShortcutsScreen.SourcesPanelShortcuts = { |
| 453 | SelectNextOccurrence: [UI.KeyboardShortcut.makeDescriptor('d', UI.KeyboardShortcut.Modifiers.CtrlOrMeta)], |
| 454 | |
| 455 | SoftUndo: [UI.KeyboardShortcut.makeDescriptor('u', UI.KeyboardShortcut.Modifiers.CtrlOrMeta)], |
| 456 | |
| 457 | GotoMatchingBracket: [UI.KeyboardShortcut.makeDescriptor('m', UI.KeyboardShortcut.Modifiers.Ctrl)], |
| 458 | |
| 459 | ToggleAutocompletion: |
| 460 | [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Space, UI.KeyboardShortcut.Modifiers.Ctrl)], |
| 461 | |
| 462 | IncreaseCSSUnitByOne: |
| 463 | [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Up, UI.KeyboardShortcut.Modifiers.Alt)], |
| 464 | |
| 465 | DecreaseCSSUnitByOne: |
| 466 | [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Down, UI.KeyboardShortcut.Modifiers.Alt)], |
| 467 | |
| 468 | IncreaseCSSUnitByTen: |
| 469 | [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.PageUp, UI.KeyboardShortcut.Modifiers.Alt)], |
| 470 | |
| 471 | DecreaseCSSUnitByTen: |
| 472 | [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.PageDown, UI.KeyboardShortcut.Modifiers.Alt)], |
| 473 | EvaluateSelectionInConsole: [UI.KeyboardShortcut.makeDescriptor( |
| 474 | 'e', UI.KeyboardShortcut.Modifiers.Shift | UI.KeyboardShortcut.Modifiers.Ctrl)], |
| 475 | |
| 476 | AddSelectionToWatch: [UI.KeyboardShortcut.makeDescriptor( |
| 477 | 'a', UI.KeyboardShortcut.Modifiers.Shift | UI.KeyboardShortcut.Modifiers.Ctrl)], |
| 478 | |
| 479 | ToggleComment: |
| 480 | [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Slash, UI.KeyboardShortcut.Modifiers.CtrlOrMeta)], |
| 481 | }; |
| 482 | |
| 483 | UI.ShortcutsScreen.LayersPanelShortcuts = { |
| 484 | ResetView: [UI.KeyboardShortcut.makeDescriptor('0')], |
| 485 | |
| 486 | PanMode: [UI.KeyboardShortcut.makeDescriptor('x')], |
| 487 | |
| 488 | RotateMode: [UI.KeyboardShortcut.makeDescriptor('v')], |
| 489 | |
| 490 | TogglePanRotate: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Shift)], |
| 491 | |
| 492 | ZoomIn: [ |
| 493 | UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Plus, UI.KeyboardShortcut.Modifiers.Shift), |
| 494 | UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.NumpadPlus) |
| 495 | ], |
| 496 | |
| 497 | ZoomOut: [ |
| 498 | UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Minus, UI.KeyboardShortcut.Modifiers.Shift), |
| 499 | UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.NumpadMinus) |
| 500 | ], |
| 501 | |
| 502 | Up: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Up), UI.KeyboardShortcut.makeDescriptor('w')], |
| 503 | |
| 504 | Down: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Down), UI.KeyboardShortcut.makeDescriptor('s')], |
| 505 | |
| 506 | Left: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Left), UI.KeyboardShortcut.makeDescriptor('a')], |
| 507 | |
| 508 | Right: [UI.KeyboardShortcut.makeDescriptor(UI.KeyboardShortcut.Keys.Right), UI.KeyboardShortcut.makeDescriptor('d')] |
| 509 | }; |