Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Side by Side Diff: chrome/browser/global_keyboard_shortcuts_cocoa_mac.mm

Issue 2696353003: Clean up the Mac shortcut tables, and make them clang-format proof. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/global_keyboard_shortcuts_views_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/macros.h" 5 #include "base/macros.h"
6 #include "chrome/app/chrome_command_ids.h" 6 #include "chrome/app/chrome_command_ids.h"
7 #include "chrome/browser/global_keyboard_shortcuts_mac.h" 7 #include "chrome/browser/global_keyboard_shortcuts_mac.h"
8 8
9 // Basically, there are two kinds of keyboard shortcuts: Ones that should work 9 // Basically, there are two kinds of keyboard shortcuts: Ones that should work
10 // only if the tab contents is focused (BrowserKeyboardShortcut), and ones that 10 // only if the tab contents is focused (BrowserKeyboardShortcut), and ones that
11 // should work in all other cases (WindowKeyboardShortcut). In the latter case, 11 // should work in all other cases (WindowKeyboardShortcut). In the latter case,
12 // we differentiate between shortcuts that are checked before any other view 12 // we differentiate between shortcuts that are checked before any other view
13 // gets the chance to handle them (WindowKeyboardShortcut) or after all views 13 // gets the chance to handle them (WindowKeyboardShortcut) or after all views
14 // had a chance but did not handle the keypress event 14 // had a chance but did not handle the keypress event
15 // (DelayedWindowKeyboardShortcut). 15 // (DelayedWindowKeyboardShortcut).
16 16
17 const std::vector<KeyboardShortcutData>& GetWindowKeyboardShortcutTable() { 17 const std::vector<KeyboardShortcutData>& GetWindowKeyboardShortcutTable() {
18 // clang-format off
18 CR_DEFINE_STATIC_LOCAL(std::vector<KeyboardShortcutData>, result, ({ 19 CR_DEFINE_STATIC_LOCAL(std::vector<KeyboardShortcutData>, result, ({
19 // cmd shift cntrl option 20 //cmd shift cntrl option vkeycode char command
20 // --- ----- ----- ------ 21 //--- ----- ----- ------ -------- ---- -------
21 // '{' / '}' characters should be matched earlier than virtual key code 22 // '{' / '}' characters should be matched earlier than virtual key codes
22 // (therefore we can match alt-8 as '{' on german keyboards). 23 // (so we can match alt-8 as '{' on German keyboards).
23 {true, false, false, false, 0, '}', IDC_SELECT_NEXT_TAB}, 24 {true, false, false, false, 0, '}', IDC_SELECT_NEXT_TAB},
24 {true, false, false, false, 0, '{', IDC_SELECT_PREVIOUS_TAB}, 25 {true, false, false, false, 0, '{', IDC_SELECT_PREVIOUS_TAB},
25 {false, false, true, false, kVK_PageDown, 0, IDC_SELECT_NEXT_TAB}, 26 {false, false, true, false, kVK_PageDown, 0, IDC_SELECT_NEXT_TAB},
26 {false, false, true, false, kVK_Tab, 0, IDC_SELECT_NEXT_TAB}, 27 {false, false, true, false, kVK_Tab, 0, IDC_SELECT_NEXT_TAB},
27 {false, false, true, false, kVK_PageUp, 0, IDC_SELECT_PREVIOUS_TAB}, 28 {false, false, true, false, kVK_PageUp, 0, IDC_SELECT_PREVIOUS_TAB},
28 {false, true, true, false, kVK_Tab, 0, IDC_SELECT_PREVIOUS_TAB}, 29 {false, true, true, false, kVK_Tab, 0, IDC_SELECT_PREVIOUS_TAB},
29 // Cmd-0..8 select the Nth tab, with cmd-9 being "last tab". 30
30 {true, false, false, false, kVK_ANSI_1, 0, IDC_SELECT_TAB_0}, 31 //cmd shift cntrl option vkeycode char command
31 {true, false, false, false, kVK_ANSI_Keypad1, 0, IDC_SELECT_TAB_0}, 32 //--- ----- ----- ------ -------- ---- -------
32 {true, false, false, false, kVK_ANSI_2, 0, IDC_SELECT_TAB_1}, 33 // Cmd-0..8 select the nth tab, with cmd-9 being "last tab".
33 {true, false, false, false, kVK_ANSI_Keypad2, 0, IDC_SELECT_TAB_1}, 34 {true, false, false, false, kVK_ANSI_1, 0, IDC_SELECT_TAB_0},
34 {true, false, false, false, kVK_ANSI_3, 0, IDC_SELECT_TAB_2}, 35 {true, false, false, false, kVK_ANSI_Keypad1, 0, IDC_SELECT_TAB_0},
35 {true, false, false, false, kVK_ANSI_Keypad3, 0, IDC_SELECT_TAB_2}, 36 {true, false, false, false, kVK_ANSI_2, 0, IDC_SELECT_TAB_1},
36 {true, false, false, false, kVK_ANSI_4, 0, IDC_SELECT_TAB_3}, 37 {true, false, false, false, kVK_ANSI_Keypad2, 0, IDC_SELECT_TAB_1},
37 {true, false, false, false, kVK_ANSI_Keypad4, 0, IDC_SELECT_TAB_3}, 38 {true, false, false, false, kVK_ANSI_3, 0, IDC_SELECT_TAB_2},
38 {true, false, false, false, kVK_ANSI_5, 0, IDC_SELECT_TAB_4}, 39 {true, false, false, false, kVK_ANSI_Keypad3, 0, IDC_SELECT_TAB_2},
39 {true, false, false, false, kVK_ANSI_Keypad5, 0, IDC_SELECT_TAB_4}, 40 {true, false, false, false, kVK_ANSI_4, 0, IDC_SELECT_TAB_3},
40 {true, false, false, false, kVK_ANSI_6, 0, IDC_SELECT_TAB_5}, 41 {true, false, false, false, kVK_ANSI_Keypad4, 0, IDC_SELECT_TAB_3},
41 {true, false, false, false, kVK_ANSI_Keypad6, 0, IDC_SELECT_TAB_5}, 42 {true, false, false, false, kVK_ANSI_5, 0, IDC_SELECT_TAB_4},
42 {true, false, false, false, kVK_ANSI_7, 0, IDC_SELECT_TAB_6}, 43 {true, false, false, false, kVK_ANSI_Keypad5, 0, IDC_SELECT_TAB_4},
43 {true, false, false, false, kVK_ANSI_Keypad7, 0, IDC_SELECT_TAB_6}, 44 {true, false, false, false, kVK_ANSI_6, 0, IDC_SELECT_TAB_5},
44 {true, false, false, false, kVK_ANSI_8, 0, IDC_SELECT_TAB_7}, 45 {true, false, false, false, kVK_ANSI_Keypad6, 0, IDC_SELECT_TAB_5},
45 {true, false, false, false, kVK_ANSI_Keypad8, 0, IDC_SELECT_TAB_7}, 46 {true, false, false, false, kVK_ANSI_7, 0, IDC_SELECT_TAB_6},
46 {true, false, false, false, kVK_ANSI_9, 0, IDC_SELECT_LAST_TAB}, 47 {true, false, false, false, kVK_ANSI_Keypad7, 0, IDC_SELECT_TAB_6},
47 {true, false, false, false, kVK_ANSI_Keypad9, 0, IDC_SELECT_LAST_TAB}, 48 {true, false, false, false, kVK_ANSI_8, 0, IDC_SELECT_TAB_7},
48 {true, true, false, false, kVK_ANSI_M, 0, IDC_SHOW_AVATAR_MENU}, 49 {true, false, false, false, kVK_ANSI_Keypad8, 0, IDC_SELECT_TAB_7},
49 {true, false, false, true, kVK_ANSI_L, 0, IDC_SHOW_DOWNLOADS}, 50 {true, false, false, false, kVK_ANSI_9, 0, IDC_SELECT_LAST_TAB},
51 {true, false, false, false, kVK_ANSI_Keypad9, 0, IDC_SELECT_LAST_TAB},
52 {true, true, false, false, kVK_ANSI_M, 0, IDC_SHOW_AVATAR_MENU},
53 {true, false, false, true, kVK_ANSI_L, 0, IDC_SHOW_DOWNLOADS},
50 })); 54 }));
55 // clang-format on
51 return result; 56 return result;
52 } 57 }
53 58
54 const std::vector<KeyboardShortcutData>& 59 const std::vector<KeyboardShortcutData>&
55 GetDelayedWindowKeyboardShortcutTable() { 60 GetDelayedWindowKeyboardShortcutTable() {
61 // clang-format off
56 CR_DEFINE_STATIC_LOCAL(std::vector<KeyboardShortcutData>, result, ({ 62 CR_DEFINE_STATIC_LOCAL(std::vector<KeyboardShortcutData>, result, ({
57 //cmd shift cntrl option 63 //cmd shift cntrl option vkeycode char command
58 //--- ----- ----- ------ 64 //--- ----- ----- ------ -------- ---- -------
59 {false, false, false, false, kVK_Escape, 0, IDC_STOP}, 65 {false, false, false, false, kVK_Escape, 0, IDC_STOP},
60 })); 66 }));
67 // clang-format on
61 return result; 68 return result;
62 } 69 }
63 70
64 const std::vector<KeyboardShortcutData>& GetBrowserKeyboardShortcutTable() { 71 const std::vector<KeyboardShortcutData>& GetBrowserKeyboardShortcutTable() {
72 // clang-format off
65 CR_DEFINE_STATIC_LOCAL(std::vector<KeyboardShortcutData>, result, ({ 73 CR_DEFINE_STATIC_LOCAL(std::vector<KeyboardShortcutData>, result, ({
66 //cmd shift cntrl option 74 //cmd shift cntrl option vkeycode char command
67 //--- ----- ----- ------ 75 //--- ----- ----- ------ -------- ---- -------
68 {true, false, false, false, kVK_LeftArrow, 0, IDC_BACK}, 76 {true, false, false, false, kVK_LeftArrow, 0, IDC_BACK},
69 {true, false, false, false, kVK_RightArrow, 0, IDC_FORWARD}, 77 {true, false, false, false, kVK_RightArrow, 0, IDC_FORWARD},
70 {false, false, false, false, kVK_Delete, 0, IDC_BACKSPACE_BACK}, 78 {false, false, false, false, kVK_Delete, 0, IDC_BACKSPACE_BACK},
71 {false, true, false, false, kVK_Delete, 0, IDC_BACKSPACE_FORWARD}, 79 {false, true, false, false, kVK_Delete, 0, IDC_BACKSPACE_FORWARD},
72 {true, true, false, false, 0, 'c', IDC_DEV_TOOLS_INSPECT}, 80 {true, true, false, false, 0, 'c', IDC_DEV_TOOLS_INSPECT},
73 })); 81 }));
82 // clang-format on
74 return result; 83 return result;
75 } 84 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/global_keyboard_shortcuts_views_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698