Meta-s triggers save event with the new css-based keymap.

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-01-10 17:42:42 -08:00
parent 6a25dc00c5
commit 4e7b1b8979
5 changed files with 12 additions and 9 deletions

View File

@@ -63,7 +63,12 @@ describe "Editor", ->
editor.getAceSession().insert {row: 0, column: 1}, 'ooo'
expect(buffer.getText()).toMatch /^.ooo/
describe "save", ->
describe ".save()", ->
it "is triggered by the 'save' event", ->
spyOn(editor, 'save')
editor.trigger('save')
expect(editor.save).toHaveBeenCalled()
describe "when the current buffer has a url", ->
beforeEach ->
buffer = new Buffer(tempFilePath)

View File

@@ -42,7 +42,3 @@ describe "Window", ->
expect(handler).toHaveBeenCalled()
describe "menu items", ->
it "adds a Save item to the main menu after startup", ->
expect(OSX.NSApp.mainMenu.itemWithTitle('File').submenu.itemWithTitle('Save')).not.toBeNull()

View File

@@ -18,6 +18,7 @@ class Editor extends Template
@aceSessions = {}
@buildAceEditor()
@setBuffer(new Buffer)
@on 'save', => @save()
shutdown: ->
@destroy()

View File

@@ -23,9 +23,9 @@ class RootView extends Template
initialize: ({url}) ->
@globalKeymap = new GlobalKeymap
@globalKeymap.bindKeys '*'
'meta+s': 'save'
'meta+w': 'close'
'meta+t': 'find-files'
'meta-s': 'save'
'meta-w': 'close'
'meta-t': 'find-files'
@editor.keyEventHandler = @globalKeymap

View File

@@ -25,7 +25,8 @@ windowAdditions =
$(window).unbind('blur')
bindMenuItems: ->
@bindMenuItem "File > Save", "meta+s", => @rootView.editor.save()
# 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}