'meta-o' presents open dialog.

This commit is contained in:
Corey Johnson
2011-12-20 10:41:31 -08:00
parent f2d9f818a8
commit d0ed5992ca
4 changed files with 32 additions and 6 deletions

View File

@@ -13,3 +13,28 @@ describe "Window", ->
spyOn(window.editor, 'save')
window.keydown 'meta+s'
expect(window.editor.save).toHaveBeenCalled()
describe 'meta+o', ->
selectedFilePath = null
beforeEach ->
spyOn(atom.native, 'openPanel').andCallFake ->
selectedFilePath
it 'presents an open dialog', ->
window.keydown 'meta+o'
expect(atom.native.openPanel).toHaveBeenCalled()
describe 'when a url is chosen', ->
it 'opens the url in the editor', ->
selectedFilePath = require.resolve 'fixtures/sample.txt'
spyOn(window.editor, 'open').andCallFake (url) -> url
window.keydown 'meta+o'
expect(window.editor.open).toHaveBeenCalledWith(selectedFilePath)
describe 'when dialog is canceled', ->
it 'does not open the editor', ->
selectedFilePath = null
spyOn(window.editor, 'open').andCallFake()
window.keydown 'meta+o'
expect(window.editor.open).not.toHaveBeenCalled()

View File

@@ -27,6 +27,10 @@ windowAdditions =
if String.fromCharCode(event.which) == 'S' and event.metaKey
@editor.save()
if String.fromCharCode(event.which) == 'O' and event.metaKey
url = atom.native.openPanel()
@editor.open(url) if url
unbindKeys: ->
$(document).unbind 'keydown'

View File

@@ -26,11 +26,7 @@ class Native
return null
filename = panel.filenames.lastObject
localStorage.lastOpenedPath = filename
filename.toString()
openURL: (url) ->
window.location = url
atom.app.activeWindow.setTitle _.last url.replace(/\/$/,'').split '/'
filename.valueOf()
# Returns null or a file path.
savePanel: ->

View File

@@ -60,5 +60,6 @@ body {
.ace_editor {
position: relative !important;
font: 18px Inconsolata, Monaco, Courier !important;
-webkit-box-flex: 1;
width: 100%;
height: 100%;
}