From fff3e19a5040e21fe88c05b00db9dac563f50965 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Thu, 10 Nov 2011 16:31:53 -0800 Subject: [PATCH] Awesome shit. --- Atom/Classes/AtomController.m | 2 -- docs/keybindings.coffee | 36 ----------------------------------- src/atom/editor.coffee | 3 ++- src/atom/key-bindings.coffee | 2 +- src/atom/window.coffee | 3 +-- src/startup.coffee | 2 +- src/stdlib/key-binder.coffee | 12 +++--------- 7 files changed, 8 insertions(+), 52 deletions(-) delete mode 100644 docs/keybindings.coffee diff --git a/Atom/Classes/AtomController.m b/Atom/Classes/AtomController.m index 483e8732e..9b7e665a0 100644 --- a/Atom/Classes/AtomController.m +++ b/Atom/Classes/AtomController.m @@ -21,8 +21,6 @@ } - (id)initWithPath:(NSString *)_path { - if (!_path) _path = @"/tmp"; // I hate this - self = [super initWithWindowNibName:@"AtomWindow"]; path = [[_path stringByStandardizingPath] retain]; diff --git a/docs/keybindings.coffee b/docs/keybindings.coffee deleted file mode 100644 index 83ceffd3c..000000000 --- a/docs/keybindings.coffee +++ /dev/null @@ -1,36 +0,0 @@ -# Keybinding ideas -# ---------------- -# Are ctrl-v and ctrl-V different? -# Nested commands? Use timeout? -# Optional Regex, is that fucking crazy? -# Command/Control/Option or cmd/ctrl/alt -# How should we deal with scope? - -keymap: - # Take some method found in the keymap scope? - 'cmd-c': 'copyText' - - # Take a block - 'cmd-v': -> paste.someText() - - # Can take a regex - # * how would this work with timeouts - # * how can this not look so hackish - # * do we even need this? - 'cmd-/(\d+)/': (number) -> - window.switchTo(parseInt(number)) - - # Nested commands - 'cmd-ctrl-r': - 'r': -> run.something() - 't': -> test.something() - - # Switch modes? I don't like this syntax - 'mode(normal):esc': - 'j': 'moveDown' - 'k': 'moveUp' - 'a': -> - goto.endOfLine() - keybindingMode('normal') - 'mode(insert):i': - 'delete': 'delete' diff --git a/src/atom/editor.coffee b/src/atom/editor.coffee index 6dee66a81..bdb9e0d78 100644 --- a/src/atom/editor.coffee +++ b/src/atom/editor.coffee @@ -9,7 +9,8 @@ ace = require 'ace/ace' module.exports = class Editor extends Document - @register (path) -> fs.isFile path + @register (path) -> + not path or fs.isFile path dirty: false path: null diff --git a/src/atom/key-bindings.coffee b/src/atom/key-bindings.coffee index e482ac53e..dd0afa323 100644 --- a/src/atom/key-bindings.coffee +++ b/src/atom/key-bindings.coffee @@ -1,10 +1,10 @@ app: 'cmd-q': (app) -> app.quit() - 'cmd-o': (app) -> app.open() window: 'cmd-shift-I': (window) -> window.showConsole() 'cmd-r': (window) -> window.reload() + 'cmd-o': (window) -> window.open() document: 'cmd-shift-d': -> console.log 'derp' diff --git a/src/atom/window.coffee b/src/atom/window.coffee index c266cecb9..917c70c89 100644 --- a/src/atom/window.coffee +++ b/src/atom/window.coffee @@ -10,7 +10,6 @@ windowAdditions = startup: -> @path = atom.path - @setTitle (_.last @path.split '/') or 'Untitled Document' $atomController.window.makeKeyWindow @@ -27,8 +26,8 @@ windowAdditions = OSX.NSApp.createController @path open: (path) -> + path = atom.native.openPanel() unless path if atom.document.open path - $atomController.window.makeKeyAndOrderFront $atomController atom.trigger 'window:open', path else atom.app.open path diff --git a/src/startup.coffee b/src/startup.coffee index 1bbf917ff..dfe2340a8 100644 --- a/src/startup.coffee +++ b/src/startup.coffee @@ -36,7 +36,7 @@ atom.path = $atomController.path?.valueOf() if handler = Document.handler atom.path atom.document = new handler atom.path else - atom.document = new Editor + throw "I DON'T KNOW ABOUT #{atom.path}" require 'window' window.startup() diff --git a/src/stdlib/key-binder.coffee b/src/stdlib/key-binder.coffee index b48472ec5..a908841bb 100644 --- a/src/stdlib/key-binder.coffee +++ b/src/stdlib/key-binder.coffee @@ -9,21 +9,15 @@ class KeyBinder keymaps: {} constructor: -> - atom.on 'window:load', -> - atom.keybinder.load require.resolve "key-bindings.coffee" - if fs.isFile "~/.atomicity/key-bindings.coffee" - atom.keybinder.load "~/.atomicity/key-bindings.coffee" + @load require.resolve "key-bindings.coffee" + if fs.isFile "~/.atomicity/key-bindings.coffee" + @load "~/.atomicity/key-bindings.coffee" register: (name, scope) -> load: (path) -> try # Watcher.watch path, => -# # Should we keep track of which file bindings are associated with? -# # That way we could clear bindings when the file is changed -# # or deleted. I think the answer is yes, but I don't want to -# # do this right now. -# console.log "#{@name}: Reloading #{path}" # @load path json = CoffeeScript.eval "return " + (fs.read path)