mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Remove menu code and tests
This commit is contained in:
@@ -10,16 +10,15 @@ RootView = require 'root-view'
|
||||
|
||||
windowAdditions =
|
||||
rootView: null
|
||||
menuItemActions: null
|
||||
keymap: null
|
||||
|
||||
startup: (url) ->
|
||||
@menuItemActions = {}
|
||||
|
||||
@setupKeymap()
|
||||
@attachRootView(url)
|
||||
@registerEventHandlers()
|
||||
@bindMenuItems()
|
||||
|
||||
$(window).on 'close', =>
|
||||
@shutdown()
|
||||
@close()
|
||||
|
||||
$(window).focus()
|
||||
atom.windowOpened this
|
||||
@@ -44,27 +43,6 @@ windowAdditions =
|
||||
return if $("head style[path='#{fullPath}']").length
|
||||
$('head').append "<style path='#{fullPath}'>#{content}</style>"
|
||||
|
||||
bindMenuItems: ->
|
||||
# we want to integrate this better with keybindings
|
||||
# @bindMenuItem "File > Save", "meta+s", => @rootView.editor.save()
|
||||
|
||||
bindMenuItem: (path, pattern, action) ->
|
||||
@menuItemActions[path] = {action: action, pattern: pattern}
|
||||
|
||||
registerEventHandlers: ->
|
||||
$(window).on 'close', =>
|
||||
@shutdown()
|
||||
@close()
|
||||
$(window).focus => @registerMenuItems()
|
||||
$(window).blur -> atom.native.resetMainMenu()
|
||||
|
||||
registerMenuItems: ->
|
||||
for path, {pattern} of @menuItemActions
|
||||
atom.native.addMenuItem(path, pattern)
|
||||
|
||||
performActionForMenuItemPath: (path) ->
|
||||
@menuItemActions[path].action()
|
||||
|
||||
showConsole: ->
|
||||
# $atomController.webView.inspector.showConsole true
|
||||
|
||||
@@ -75,7 +53,6 @@ for key, value of windowAdditions
|
||||
console.warn "DOMWindow already has a key named `#{key}`" if window[key]
|
||||
window[key] = value
|
||||
|
||||
|
||||
requireStylesheet 'reset.css'
|
||||
requireStylesheet 'atom.css'
|
||||
|
||||
|
||||
@@ -35,42 +35,4 @@ class Native
|
||||
atom.native.writeToPasteboard text
|
||||
|
||||
readFromPasteboard: ->
|
||||
atom.native.readFromPasteboard()
|
||||
|
||||
resetMainMenu: (menu) ->
|
||||
# OSX.NSApp.resetMainMenu
|
||||
|
||||
addMenuItem: (itemPath, keyPattern) ->
|
||||
itemPathComponents = itemPath.split /\s*>\s*/
|
||||
submenu = @buildSubmenuPath(OSX.NSApp.mainMenu, itemPathComponents[0..-2])
|
||||
title = _.last(itemPathComponents)
|
||||
unless submenu.itemWithTitle(title)
|
||||
item = OSX.AtomMenuItem.alloc.initWithTitle_itemPath(title, itemPath).autorelease
|
||||
item.setKeyEquivalentModifierMask 0 # Because in Cocoa defaults it to NSCommandKeyMask
|
||||
|
||||
if keyPattern
|
||||
bindingSet = new (require('binding-set'))("*", {})
|
||||
keys = bindingSet.parseKeyPattern keyPattern
|
||||
|
||||
modifierMask = (keys.metaKey and OSX.NSCommandKeyMask ) |
|
||||
(keys.shiftKey and OSX.NSShiftKeyMask) |
|
||||
(keys.altKey and OSX.NSAlternateKeyMask) |
|
||||
(keys.ctrlKey and OSX.NSControlKeyMask)
|
||||
|
||||
item.setKeyEquivalent keys.key
|
||||
item.setKeyEquivalentModifierMask modifierMask
|
||||
submenu.addItem(item)
|
||||
|
||||
buildSubmenuPath: (menu, path) ->
|
||||
return menu if path.length == 0
|
||||
|
||||
first = path[0]
|
||||
unless item = menu.itemWithTitle(first)
|
||||
item = OSX.AtomMenuItem.alloc.initWithTitle_action_keyEquivalent(first, null, "").autorelease
|
||||
menu.addItem(item)
|
||||
unless submenu = item.submenu
|
||||
submenu = OSX.NSMenu.alloc.initWithTitle(first)
|
||||
item.submenu = submenu
|
||||
|
||||
@buildSubmenuPath(submenu, path[1..-1])
|
||||
|
||||
atom.native.readFromPasteboard()
|
||||
Reference in New Issue
Block a user