mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Rename keystrokeByCommmand to keystrokesByCommmand
This commit is contained in:
@@ -20,11 +20,11 @@ class ApplicationMenu
|
||||
#
|
||||
# * template:
|
||||
# The Object which describes the menu to display.
|
||||
# * keystrokeByCommand:
|
||||
# * keystrokesByCommand:
|
||||
# An Object where the keys are commands and the values are Arrays containing
|
||||
# the keystroke.
|
||||
update: (template, keystrokeByCommand) ->
|
||||
@translateTemplate(template, keystrokeByCommand)
|
||||
update: (template, keystrokesByCommand) ->
|
||||
@translateTemplate(template, keystrokesByCommand)
|
||||
@substituteVersion(template)
|
||||
@menu = Menu.buildFromTemplate(template)
|
||||
Menu.setApplicationMenu(@menu)
|
||||
@@ -102,33 +102,33 @@ class ApplicationMenu
|
||||
# * template:
|
||||
# An Object conforming to atom-shell's menu api but lacking accelerator and
|
||||
# click properties.
|
||||
# * keystrokeByCommand:
|
||||
# * keystrokesByCommand:
|
||||
# An Object where the keys are commands and the values are Arrays containing
|
||||
# the keystroke.
|
||||
#
|
||||
# Returns a complete menu configuration object for atom-shell's menu API.
|
||||
translateTemplate: (template, keystrokeByCommand) ->
|
||||
translateTemplate: (template, keystrokesByCommand) ->
|
||||
template.forEach (item) =>
|
||||
item.metadata = {}
|
||||
if item.command
|
||||
item.accelerator = @acceleratorForCommand(item.command, keystrokeByCommand)
|
||||
item.accelerator = @acceleratorForCommand(item.command, keystrokesByCommand)
|
||||
item.click = => global.atomApplication.sendCommand(item.command)
|
||||
item.metadata['windowSpecific'] = true unless /^application:/.test(item.command)
|
||||
@translateTemplate(item.submenu, keystrokeByCommand) if item.submenu
|
||||
@translateTemplate(item.submenu, keystrokesByCommand) if item.submenu
|
||||
template
|
||||
|
||||
# Private: Determine the accelerator for a given command.
|
||||
#
|
||||
# * command:
|
||||
# The name of the command.
|
||||
# * keystrokeByCommand:
|
||||
# * keystrokesByCommand:
|
||||
# An Object where the keys are commands and the values are Arrays containing
|
||||
# the keystroke.
|
||||
#
|
||||
# Returns a String containing the keystroke in a format that can be interpreted
|
||||
# by atom shell to provide nice icons where available.
|
||||
acceleratorForCommand: (command, keystrokeByCommand) ->
|
||||
firstKeystroke = keystrokeByCommand[command]?[0]
|
||||
acceleratorForCommand: (command, keystrokesByCommand) ->
|
||||
firstKeystroke = keystrokesByCommand[command]?[0]
|
||||
return null unless firstKeystroke
|
||||
|
||||
modifiers = firstKeystroke.split('-')
|
||||
|
||||
@@ -176,8 +176,8 @@ class AtomApplication
|
||||
else
|
||||
@promptForPath()
|
||||
|
||||
ipc.on 'update-application-menu', (processId, routingId, template, keystrokeByCommand) =>
|
||||
@applicationMenu.update(template, keystrokeByCommand)
|
||||
ipc.on 'update-application-menu', (processId, routingId, template, keystrokesByCommand) =>
|
||||
@applicationMenu.update(template, keystrokesByCommand)
|
||||
|
||||
ipc.on 'run-package-specs', (processId, routingId, specDirectory) =>
|
||||
@runSpecs({resourcePath: global.devResourcePath, specDirectory: specDirectory, exitWhenDone: false})
|
||||
|
||||
@@ -34,7 +34,7 @@ class MenuManager
|
||||
for mapping in atom.keymap.allMappings() when mapping.selector in selectors
|
||||
keystrokesByCommand[mapping.command] ?= []
|
||||
keystrokesByCommand[mapping.command].push mapping.keystroke
|
||||
@sendToBrowserProcess(@template, keystrokeByCommand)
|
||||
@sendToBrowserProcess(@template, keystrokesByCommand)
|
||||
|
||||
# Private
|
||||
loadCoreItems: ->
|
||||
@@ -56,9 +56,9 @@ class MenuManager
|
||||
# Private: OSX can't handle displaying accelerators for multiple keystrokes.
|
||||
# If they are sent across, it will stop processing accelerators for the rest
|
||||
# of the menu items.
|
||||
filterMultipleKeystroke: (keystrokeByCommand) ->
|
||||
filterMultipleKeystroke: (keystrokesByCommand) ->
|
||||
filtered = {}
|
||||
for key, bindings of keystrokeByCommand
|
||||
for key, bindings of keystrokesByCommand
|
||||
for binding in bindings
|
||||
continue if binding.indexOf(' ') != -1
|
||||
|
||||
@@ -67,6 +67,6 @@ class MenuManager
|
||||
filtered
|
||||
|
||||
# Private
|
||||
sendToBrowserProcess: (template, keystrokeByCommand) ->
|
||||
keystrokeByCommand = @filterMultipleKeystroke(keystrokeByCommand)
|
||||
ipc.sendChannel 'update-application-menu', template, keystrokeByCommand
|
||||
sendToBrowserProcess: (template, keystrokesByCommand) ->
|
||||
keystrokesByCommand = @filterMultipleKeystroke(keystrokesByCommand)
|
||||
ipc.sendChannel 'update-application-menu', template, keystrokesByCommand
|
||||
|
||||
Reference in New Issue
Block a user