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