mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Menu bar does not directly access the keymap anymore
This makes the keyBindingsForCommand methods obsolete
This commit is contained in:
committed by
Corey Johnson & Nathan Sobo
parent
37c17075ea
commit
6e3517dd4a
@@ -2,7 +2,7 @@ ipc = require 'ipc'
|
||||
|
||||
module.exports =
|
||||
class MenuBar
|
||||
@show: ->
|
||||
@show: (keyBindingsByCommand) ->
|
||||
atomMenu =
|
||||
label: 'Atom'
|
||||
submenu: [
|
||||
@@ -67,18 +67,17 @@ class MenuBar
|
||||
label: '\uD83D\uDC80' # Skull emoji
|
||||
submenu: [ { label: 'In Development Mode', enabled: false } ]
|
||||
|
||||
@addKeyBindings(menu)
|
||||
@addKeyBindings(menu, keyBindingsByCommand)
|
||||
ipc.sendChannel 'build-menu-bar-from-template', menu
|
||||
|
||||
@addKeyBindings: (menuItems) ->
|
||||
@addKeyBindings: (menuItems, keyBindingsByCommand) ->
|
||||
for menuItem in menuItems
|
||||
if menuItem.command
|
||||
menuItem.accelerator = @acceleratorForCommand(menuItem.command)
|
||||
@addKeyBindings(menuItem.submenu) if menuItem.submenu
|
||||
menuItem.accelerator = @acceleratorForCommand(menuItem.command, keyBindingsByCommand)
|
||||
@addKeyBindings(menuItem.submenu, keyBindingsByCommand) if menuItem.submenu
|
||||
|
||||
@acceleratorForCommand: (command) ->
|
||||
keyBindings = keymap.keyBindingsForCommand(command)
|
||||
keyBinding = keyBindings[0]
|
||||
@acceleratorForCommand: (command, keyBindingsByCommand) ->
|
||||
keyBinding = keyBindingsByCommand[command]?[0]
|
||||
return null unless keyBinding
|
||||
|
||||
modifiers = keyBinding.split('-')
|
||||
|
||||
@@ -28,12 +28,6 @@ class BindingSet
|
||||
return command if event.keystrokes == keystrokes
|
||||
null
|
||||
|
||||
keyBindingsForCommand: (desiredCommand) ->
|
||||
keyBindings = []
|
||||
for keystrokes, command of @commandsByKeystrokes
|
||||
keyBindings.push(keystrokes) if command == desiredCommand
|
||||
keyBindings
|
||||
|
||||
matchesKeystrokePrefix: (event) ->
|
||||
eventKeystrokes = event.keystrokes.split(' ')
|
||||
for keystrokes, command of @commandsByKeystrokes
|
||||
|
||||
@@ -163,12 +163,6 @@ class Keymap
|
||||
|
||||
[modifiers..., key].join('-')
|
||||
|
||||
keyBindingsForCommand: (command) ->
|
||||
keyBindings = []
|
||||
for bindingSet in @bindingSets
|
||||
keyBindings = keyBindings.concat(bindingSet.keyBindingsForCommand(command))
|
||||
keyBindings
|
||||
|
||||
toObject: ->
|
||||
keyBindingsForCommands = {}
|
||||
for bindingSet in @bindingSets
|
||||
|
||||
@@ -55,7 +55,7 @@ window.startEditorWindow = ->
|
||||
atom.activatePackages()
|
||||
keymap.loadUserKeymaps()
|
||||
atom.requireUserInitScript()
|
||||
MenuBar.show()
|
||||
MenuBar.show(keymap.toObject())
|
||||
$(window).on 'unload', -> unloadEditorWindow(); false
|
||||
atom.show()
|
||||
atom.focus()
|
||||
|
||||
Reference in New Issue
Block a user