mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Listen for application commands using the @command method
This adds application level commands to the command palette.
This commit is contained in:
committed by
Corey Johnson & Nathan Sobo
parent
ab397b306c
commit
39ec96021e
@@ -137,6 +137,9 @@ class AtomApplication
|
||||
ipc.once 'keymap-loaded', (processId, routingId, keyBindingsByCommand) =>
|
||||
@applicationMenu.update(keyBindingsByCommand)
|
||||
|
||||
ipc.on 'command', (processId, routingId, command) =>
|
||||
@emit(command)
|
||||
|
||||
sendCommand: (command, args...) ->
|
||||
return if @emit(command, args...)
|
||||
return if @interceptAlternativeWindowCommands(command)
|
||||
|
||||
@@ -96,7 +96,7 @@ class Keymap
|
||||
candidateBindingSets = @bindingSetsForNode(currentNode, bindingSetsForFirstKeystroke)
|
||||
for bindingSet in candidateBindingSets
|
||||
command = bindingSet.commandForEvent(event)
|
||||
if command is 'native!' or /^application:/i.test(command)
|
||||
if command is 'native!'
|
||||
return true
|
||||
else if command
|
||||
continue if @triggerCommandEvent(event, command)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
ipc = require 'ipc'
|
||||
path = require 'path'
|
||||
$ = require 'jquery'
|
||||
{$$} = require 'space-pen'
|
||||
@@ -65,6 +66,21 @@ class RootView extends View
|
||||
@on 'pane:removed', => @updateTitle() unless @getActivePane()
|
||||
@on 'pane:active-item-title-changed', '.active.pane', => @updateTitle()
|
||||
|
||||
@command 'application:about', -> ipc.sendChannel('command', 'application:about')
|
||||
@command 'application:run-specs', -> ipc.sendChannel('command', 'application:run-specs')
|
||||
@command 'application:show-settings', -> ipc.sendChannel('command', 'application:show-settings')
|
||||
@command 'application:quit', -> ipc.sendChannel('command', 'application:quit')
|
||||
@command 'application:hide', -> ipc.sendChannel('command', 'application:hide')
|
||||
@command 'application:hide-other-applications', -> ipc.sendChannel('command', 'application:hide-other-applications')
|
||||
@command 'application:unhide-all-applications', -> ipc.sendChannel('command', 'application:unhide-all-applications')
|
||||
@command 'application:new-window', -> ipc.sendChannel('command', 'application:new-window')
|
||||
@command 'application:new-file', -> ipc.sendChannel('command', 'application:new-file')
|
||||
@command 'application:open', -> ipc.sendChannel('command', 'application:open')
|
||||
@command 'application:open-dev', -> ipc.sendChannel('command', 'application:open-dev')
|
||||
@command 'application:minimize', -> ipc.sendChannel('command', 'application:minimize')
|
||||
@command 'application:zoom', -> ipc.sendChannel('command', 'application:zoom')
|
||||
@command 'application:bring-all-windows-to-front', -> ipc.sendChannel('command', 'application:bring-all-windows-to-front')
|
||||
|
||||
@command 'window:increase-font-size', =>
|
||||
config.set("editor.fontSize", config.get("editor.fontSize") + 1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user