From 39ec96021e5f413197dff2239e67d6b75b0b7d83 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Mon, 19 Aug 2013 14:37:43 -0700 Subject: [PATCH] Listen for application commands using the @command method This adds application level commands to the command palette. --- src/atom-application.coffee | 3 +++ src/keymap.coffee | 2 +- src/root-view.coffee | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/atom-application.coffee b/src/atom-application.coffee index 0b6ec80fc..cbca5628c 100644 --- a/src/atom-application.coffee +++ b/src/atom-application.coffee @@ -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) diff --git a/src/keymap.coffee b/src/keymap.coffee index 81825a7dd..e91ea27f3 100644 --- a/src/keymap.coffee +++ b/src/keymap.coffee @@ -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) diff --git a/src/root-view.coffee b/src/root-view.coffee index 6679f0854..b62b99458 100644 --- a/src/root-view.coffee +++ b/src/root-view.coffee @@ -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)