mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Merge remote-tracking branch 'origin/key-bindings'
Conflicts: src/startup.coffee
This commit is contained in:
@@ -27,6 +27,6 @@
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<string>AtomApp</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
046973A414145A9500415518 /* AtomApp.m in Sources */ = {isa = PBXBuildFile; fileRef = 046973A314145A9500415518 /* AtomApp.m */; };
|
||||
83599F9B13FE0F8400AC37E3 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83599F9A13FE0F8400AC37E3 /* WebKit.framework */; };
|
||||
8359A6EE13FE26DA00AC37E3 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8359A6ED13FE26DA00AC37E3 /* JavaScriptCore.framework */; };
|
||||
837D8BA81408FAAA009B6DFA /* AtomicityAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 837D8BA51408FAAA009B6DFA /* AtomicityAppDelegate.m */; };
|
||||
837D8BA91408FAAA009B6DFA /* AtomWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 837D8BA71408FAAA009B6DFA /* AtomWindowController.m */; };
|
||||
837D8BAC1408FAB4009B6DFA /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 837D8BAB1408FAB4009B6DFA /* main.m */; };
|
||||
837D8BB41408FAC3009B6DFA /* APPL.icns in Resources */ = {isa = PBXBuildFile; fileRef = 837D8BAD1408FAC3009B6DFA /* APPL.icns */; };
|
||||
@@ -28,14 +28,14 @@
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
046973A214145A9500415518 /* AtomApp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AtomApp.h; path = Classes/AtomApp.h; sourceTree = "<group>"; };
|
||||
046973A314145A9500415518 /* AtomApp.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AtomApp.m; path = Classes/AtomApp.m; sourceTree = "<group>"; };
|
||||
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
|
||||
13E42FB307B3F0F600E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
|
||||
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
|
||||
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
|
||||
83599F9A13FE0F8400AC37E3 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
|
||||
8359A6ED13FE26DA00AC37E3 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
|
||||
837D8BA41408FAAA009B6DFA /* AtomicityAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AtomicityAppDelegate.h; path = ../../Atomicity/Cocoa/Classes/AtomicityAppDelegate.h; sourceTree = SOURCE_ROOT; };
|
||||
837D8BA51408FAAA009B6DFA /* AtomicityAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AtomicityAppDelegate.m; path = ../../Atomicity/Cocoa/Classes/AtomicityAppDelegate.m; sourceTree = SOURCE_ROOT; };
|
||||
837D8BA61408FAAA009B6DFA /* AtomWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AtomWindowController.h; path = ../../Atomicity/Cocoa/Classes/AtomWindowController.h; sourceTree = SOURCE_ROOT; };
|
||||
837D8BA71408FAAA009B6DFA /* AtomWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AtomWindowController.m; path = ../../Atomicity/Cocoa/Classes/AtomWindowController.m; sourceTree = SOURCE_ROOT; };
|
||||
837D8BAA1408FAB4009B6DFA /* Atomicity_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Atomicity_Prefix.pch; path = ../../Atomicity/Cocoa/Atomicity_Prefix.pch; sourceTree = SOURCE_ROOT; };
|
||||
@@ -80,8 +80,8 @@
|
||||
080E96DDFE201D6D7F000001 /* Classes */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
837D8BA41408FAAA009B6DFA /* AtomicityAppDelegate.h */,
|
||||
837D8BA51408FAAA009B6DFA /* AtomicityAppDelegate.m */,
|
||||
046973A214145A9500415518 /* AtomApp.h */,
|
||||
046973A314145A9500415518 /* AtomApp.m */,
|
||||
837D8BA61408FAAA009B6DFA /* AtomWindowController.h */,
|
||||
837D8BA71408FAAA009B6DFA /* AtomWindowController.m */,
|
||||
29B97315FDCFA39411CA2CEA /* Other Sources */,
|
||||
@@ -267,7 +267,6 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
837D8BA81408FAAA009B6DFA /* AtomicityAppDelegate.m in Sources */,
|
||||
837D8BA91408FAAA009B6DFA /* AtomWindowController.m in Sources */,
|
||||
837D8BAC1408FAB4009B6DFA /* main.m in Sources */,
|
||||
837D8BD51408FAD4009B6DFA /* BridgeSupportController.m in Sources */,
|
||||
@@ -276,6 +275,7 @@
|
||||
837D8BD91408FAD4009B6DFA /* JSCocoaFFIClosure.m in Sources */,
|
||||
837D8BDA1408FAD4009B6DFA /* JSCocoaLib.m in Sources */,
|
||||
837D8BDB1408FAD4009B6DFA /* JSCocoaPrivateObject.m in Sources */,
|
||||
046973A414145A9500415518 /* AtomApp.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
5
Cocoa/Classes/AtomApp.h
Normal file
5
Cocoa/Classes/AtomApp.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface AtomApp : NSApplication <NSApplicationDelegate>
|
||||
|
||||
@end
|
||||
39
Cocoa/Classes/AtomApp.m
Normal file
39
Cocoa/Classes/AtomApp.m
Normal file
@@ -0,0 +1,39 @@
|
||||
#import "AtomApp.h"
|
||||
#import "AtomWindowController.h"
|
||||
#import "JSCocoa.h"
|
||||
|
||||
@implementation AtomApp
|
||||
|
||||
- (void)sendEvent:(NSEvent *)event {
|
||||
switch ([event type]) {
|
||||
case NSKeyDown:
|
||||
case NSFlagsChanged:
|
||||
{
|
||||
AtomWindowController *controller = (AtomWindowController *)[[self keyWindow] windowController];
|
||||
BOOL handeled = [controller handleKeyEvent:event];
|
||||
if (!handeled) {
|
||||
[super sendEvent:event];
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
[super sendEvent:event];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// AppDelegate
|
||||
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification {
|
||||
NSDictionary *defaults = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithBool:YES], @"WebKitDeveloperExtras",
|
||||
nil];
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
|
||||
id c = [[AtomWindowController alloc] initWithWindowNibName:@"AtomWindow"];
|
||||
[c window];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@@ -8,12 +8,17 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@class JSCocoa;
|
||||
|
||||
@interface AtomWindowController : NSWindowController {
|
||||
IBOutlet id webView;
|
||||
NSString *URL;
|
||||
JSCocoa* jscocoa;
|
||||
}
|
||||
|
||||
@property (assign) IBOutlet id webView;
|
||||
@property (assign) IBOutlet NSString *URL;
|
||||
|
||||
-(BOOL) handleKeyEvent:(NSEvent *)event;
|
||||
|
||||
@end
|
||||
|
||||
@@ -23,27 +23,34 @@
|
||||
|
||||
- (void)windowDidLoad {
|
||||
[super windowDidLoad];
|
||||
|
||||
|
||||
|
||||
[self setShouldCascadeWindows:YES];
|
||||
[self setWindowFrameAutosaveName:@"atomWindow"];
|
||||
|
||||
|
||||
if (self.URL) {
|
||||
[webView setMainFrameURL:self.URL];
|
||||
}
|
||||
}
|
||||
else {
|
||||
jscocoa = [[JSCocoa alloc] initWithGlobalContext:[[webView mainFrame] globalContext]];
|
||||
[jscocoa setObject:self withName:@"WindowController"];
|
||||
|
||||
NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
|
||||
NSString *bootstrapPath = [resourcePath stringByAppendingString:@"/src/require.js"];
|
||||
JSCocoa* jsc = [[JSCocoa alloc] initWithGlobalContext:[[webView mainFrame] globalContext]];
|
||||
[jsc setObject:self withName:@"WindowController"];
|
||||
[jsc evalJSFile:bootstrapPath];
|
||||
NSString *requirePath = [resourcePath stringByAppendingString:@"/src/require.js"];
|
||||
[jscocoa evalJSFile:requirePath];
|
||||
|
||||
NSURL *resourceURL = [[NSBundle mainBundle] resourceURL];
|
||||
NSURL *htmlURL = [resourceURL URLByAppendingPathComponent:@"static"];
|
||||
NSURL *indexURL = [htmlURL URLByAppendingPathComponent:@"index.html"];
|
||||
NSString *html = [NSString stringWithContentsOfURL:indexURL encoding:NSUTF8StringEncoding error:nil];
|
||||
[[webView mainFrame] loadHTMLString:html baseURL:htmlURL];
|
||||
[[webView mainFrame] loadHTMLString:html baseURL:htmlURL];
|
||||
}
|
||||
}
|
||||
|
||||
-(BOOL) handleKeyEvent:(NSEvent *)event {
|
||||
// ICKY: Using a global function defined in App.js to deal with key events
|
||||
JSValueRef returnValue = [jscocoa callJSFunctionNamed:@"handleKeyEvent" withArguments:event, nil];
|
||||
return [jscocoa toBool:returnValue];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
//
|
||||
// AtomicityAppDelegate.h
|
||||
// Atomicity
|
||||
//
|
||||
// Created by Chris Wanstrath on 8/18/11.
|
||||
// Copyright 2011 GitHub. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface AtomicityAppDelegate : NSObject <NSApplicationDelegate> {
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,27 +0,0 @@
|
||||
//
|
||||
// AtomicityAppDelegate.m
|
||||
// Atomicity
|
||||
//
|
||||
// Created by Chris Wanstrath on 8/18/11.
|
||||
// Copyright 2011 GitHub. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AtomicityAppDelegate.h"
|
||||
#import "AtomWindowController.h"
|
||||
#import "JSCocoa.h"
|
||||
|
||||
@implementation AtomicityAppDelegate
|
||||
|
||||
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification {
|
||||
NSDictionary *defaults = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithBool:YES], @"WebKitDeveloperExtras",
|
||||
nil];
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
|
||||
id c = [[AtomWindowController alloc] initWithWindowNibName:@"AtomWindow"];
|
||||
[c window];
|
||||
}
|
||||
|
||||
@end
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,9 @@ paths = [
|
||||
"/Users/chris/Code/Atomicity/src",
|
||||
"/Users/chris/Code/Atomicity/plugins",
|
||||
|
||||
"/Users/corey/code/mine/Atomicity/src",
|
||||
"/Users/corey/code/mine/Atomicity/plugins",
|
||||
|
||||
"#{resourcePath}/src",
|
||||
"#{resourcePath}/plugins",
|
||||
"#{resourcePath}/vendor"
|
||||
|
||||
@@ -3,7 +3,18 @@ App = require 'app'
|
||||
Window = require 'window'
|
||||
App.setActiveWindow new Window controller: WindowController
|
||||
|
||||
window.handleKeyEvent = (event) ->
|
||||
if event.keyCode == 50
|
||||
console.log("Got `")
|
||||
true
|
||||
else if (event.modifierFlags & OSX.NSCommandKeyMask) and event.keyCode == 12 # cmd and q pushed
|
||||
console.log("Cmd-Q")
|
||||
true
|
||||
else
|
||||
console.log(event.keyCode)
|
||||
false
|
||||
|
||||
Editor = require 'editor'
|
||||
App.activeWindow.document = new Editor
|
||||
|
||||
require 'plugins'
|
||||
require 'plugins'
|
||||
|
||||
Reference in New Issue
Block a user