mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
coffeescript, open file works
This commit is contained in:
35
HTML/atomicity.coffee
Normal file
35
HTML/atomicity.coffee
Normal file
@@ -0,0 +1,35 @@
|
||||
console.log = OSX.NSLog
|
||||
|
||||
editor = ace.edit "editor"
|
||||
editor.setTheme "ace/theme/twilight"
|
||||
JavaScriptMode = require("ace/mode/javascript").Mode
|
||||
editor.getSession().setMode new JavaScriptMode()
|
||||
|
||||
canon = require 'pilot/canon'
|
||||
|
||||
bindKey = (name, shortcut, callback) ->
|
||||
canon.addCommand
|
||||
name: name
|
||||
exec: callback
|
||||
bindKey:
|
||||
win: null
|
||||
mac: shortcut
|
||||
sender: 'editor'
|
||||
|
||||
bindKey 'open', 'Command-O', (env, args, request) ->
|
||||
panel = OSX.NSOpenPanel.openPanel
|
||||
|
||||
if panel.runModal isnt OSX.NSFileHandlingPanelOKButton
|
||||
return null
|
||||
|
||||
if file = panel.filenames.lastObject
|
||||
env.editor.getSession().setValue OSX.NSString.stringWithContentsOfFile file
|
||||
|
||||
bindKey 'eval', 'Command-R', (env, args, request) ->
|
||||
eval env.editor.getSession().getValue()
|
||||
|
||||
bindKey 'togglecomment', 'Command-/', (env) ->
|
||||
env.editor.toggleCommentLines()
|
||||
|
||||
bindKey 'fullscreen', 'Command-Return', (env) ->
|
||||
OSX.NSLog 'coming soon'
|
||||
@@ -1,6 +1,39 @@
|
||||
window.onload = function() {
|
||||
var editor = ace.edit("editor");
|
||||
(function() {
|
||||
var JavaScriptMode, bindKey, canon, editor;
|
||||
console.log = OSX.NSLog;
|
||||
editor = ace.edit("editor");
|
||||
editor.setTheme("ace/theme/twilight");
|
||||
var JavaScriptMode = require("ace/mode/javascript").Mode;
|
||||
JavaScriptMode = require("ace/mode/javascript").Mode;
|
||||
editor.getSession().setMode(new JavaScriptMode());
|
||||
};
|
||||
canon = require('pilot/canon');
|
||||
bindKey = function(name, shortcut, callback) {
|
||||
return canon.addCommand({
|
||||
name: name,
|
||||
exec: callback,
|
||||
bindKey: {
|
||||
win: null,
|
||||
mac: shortcut,
|
||||
sender: 'editor'
|
||||
}
|
||||
});
|
||||
};
|
||||
bindKey('open', 'Command-O', function(env, args, request) {
|
||||
var file, panel;
|
||||
panel = OSX.NSOpenPanel.openPanel;
|
||||
if (panel.runModal !== OSX.NSFileHandlingPanelOKButton) {
|
||||
return null;
|
||||
}
|
||||
if (file = panel.filenames.lastObject) {
|
||||
return env.editor.getSession().setValue(OSX.NSString.stringWithContentsOfFile(file));
|
||||
}
|
||||
});
|
||||
bindKey('eval', 'Command-R', function(env, args, request) {
|
||||
return eval(env.editor.getSession().getValue());
|
||||
});
|
||||
bindKey('togglecomment', 'Command-/', function(env) {
|
||||
return env.editor.toggleCommentLines();
|
||||
});
|
||||
bindKey('fullscreen', 'Command-Return', function(env) {
|
||||
return OSX.NSLog('coming soon');
|
||||
});
|
||||
}).call(this);
|
||||
|
||||
Reference in New Issue
Block a user