mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Add facility for running specs… still don't have any yet.
Use property accessors instead of raw ivars.
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
@synthesize controllers;
|
||||
|
||||
- (AtomController *)createController:(NSString *)path {
|
||||
AtomController *controller = [[AtomController alloc] initWithURL:path];
|
||||
AtomController *controller = [(AtomController *)[AtomController alloc] initWithURL:path];
|
||||
[controllers addObject:controller];
|
||||
|
||||
return controller;
|
||||
@@ -23,6 +23,11 @@
|
||||
[controller.jscocoa callJSFunctionNamed:@"triggerEvent" withArguments:@"window:close", nil, false, nil];
|
||||
}
|
||||
|
||||
- (void)runSpecs {
|
||||
AtomController *controller = [(AtomController *)[AtomController alloc] initForSpecs];
|
||||
[controllers addObject:controller];
|
||||
}
|
||||
|
||||
- (void)reloadController:(AtomController *)controller {
|
||||
CGRect frame = [[controller window] frame];
|
||||
AtomController *newController = [self createController:controller.url];
|
||||
@@ -55,10 +60,10 @@
|
||||
[super sendEvent:event];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
BOOL handeled = NO;
|
||||
AtomController *controller = [[self keyWindow] windowController];
|
||||
|
||||
|
||||
// The keyWindow could be a Cocoa Dialog or something, ignore those.
|
||||
if ([controller isKindOfClass:[AtomController class]]) {
|
||||
// cmd-r should always reload the current controller, so it needs to be here
|
||||
@@ -66,6 +71,10 @@
|
||||
[self reloadController:controller];
|
||||
handeled = YES;
|
||||
}
|
||||
else if ([event modifierFlags] & (NSAlternateKeyMask | NSControlKeyMask | NSCommandKeyMask) && [[event charactersIgnoringModifiers] hasPrefix:@"s"]) {
|
||||
[self runSpecs];
|
||||
handeled = YES;
|
||||
}
|
||||
else {
|
||||
JSValueRef value = [controller.jscocoa callJSFunctionNamed:@"handleKeyEvent" withArguments:event, nil];
|
||||
handeled = [controller.jscocoa toBool:value];
|
||||
|
||||
@@ -7,9 +7,12 @@
|
||||
}
|
||||
|
||||
@property (retain) WebView *webView;
|
||||
@property (retain, readonly) NSString *url;
|
||||
@property (retain) JSCocoa *jscocoa;
|
||||
@property (nonatomic, retain) JSCocoa *jscocoa;
|
||||
|
||||
@property (nonatomic, retain, readonly) NSString *url;
|
||||
@property (nonatomic, retain, readonly) NSString *bootstrapPage;
|
||||
|
||||
- (id)initForSpecs;
|
||||
- (AtomController *)initWithURL:(NSString *)url;
|
||||
|
||||
@end
|
||||
|
||||
@@ -2,54 +2,75 @@
|
||||
#import "AtomApp.h"
|
||||
|
||||
#import "JSCocoa.h"
|
||||
|
||||
#import <WebKit/WebKit.h>
|
||||
|
||||
@interface AtomController ()
|
||||
|
||||
@property (nonatomic, retain, readwrite) NSString *url;
|
||||
@property (nonatomic, retain, readwrite) NSString *bootstrapPage;
|
||||
|
||||
@end
|
||||
|
||||
@implementation AtomController
|
||||
|
||||
@synthesize webView, url, jscocoa;
|
||||
@synthesize
|
||||
webView = _webView,
|
||||
jscocoa = _jscocoa,
|
||||
url = _url,
|
||||
bootstrapPage = _bootstrapPage;
|
||||
|
||||
- (void)dealloc {
|
||||
[jscocoa unlinkAllReferences];
|
||||
[jscocoa garbageCollect];
|
||||
[jscocoa release]; jscocoa = nil;
|
||||
|
||||
[webView release];
|
||||
[url release];
|
||||
[self.jscocoa unlinkAllReferences];
|
||||
[self.jscocoa garbageCollect];
|
||||
self.jscocoa = nil;
|
||||
self.webView = nil;
|
||||
self.bootstrapPage = nil;
|
||||
self.url = nil;
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id)initWithURL:(NSString *)_url {
|
||||
self = [super initWithWindowNibName:@"AtomWindow"];
|
||||
url = [_url retain];
|
||||
|
||||
[self.window makeKeyWindow];
|
||||
- (id)initWithBootstrapPage:(NSString *)bootstrapPage url:(NSString *)url {
|
||||
self = [super initWithWindowNibName:@"AtomWindow"];
|
||||
self.bootstrapPage = bootstrapPage;
|
||||
self.url = url;
|
||||
|
||||
[self.window makeKeyWindow];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (id)initForSpecs {
|
||||
return [self initWithBootstrapPage:@"spec-suite.html" url:nil];
|
||||
}
|
||||
|
||||
- (id)initWithURL:(NSString *)url {
|
||||
return [self initWithBootstrapPage:@"index.html" url:url];
|
||||
}
|
||||
|
||||
- (void)windowDidLoad {
|
||||
[super windowDidLoad];
|
||||
|
||||
[self.window setDelegate:self];
|
||||
[self.window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
||||
|
||||
[webView setUIDelegate:self];
|
||||
[self.webView setUIDelegate:self];
|
||||
|
||||
[self setShouldCascadeWindows:YES];
|
||||
[self setWindowFrameAutosaveName:@"atomController"];
|
||||
|
||||
jscocoa = [[JSCocoa alloc] initWithGlobalContext:[[webView mainFrame] globalContext]];
|
||||
[jscocoa setObject:self withName:@"$atomController"];
|
||||
self.jscocoa = [[JSCocoa alloc] initWithGlobalContext:[[self.webView mainFrame] globalContext]];
|
||||
[self.jscocoa setObject:self withName:@"$atomController"];
|
||||
|
||||
NSURL *resourceURL = [[NSBundle mainBundle] resourceURL];
|
||||
NSURL *indexURL = [resourceURL URLByAppendingPathComponent:@"index.html"];
|
||||
NSURL *bootstrapPageURL = [resourceURL URLByAppendingPathComponent:self.bootstrapPage];
|
||||
|
||||
NSURLRequest *request = [NSURLRequest requestWithURL:indexURL];
|
||||
[[webView mainFrame] loadRequest:request];
|
||||
NSURLRequest *request = [NSURLRequest requestWithURL:bootstrapPageURL];
|
||||
[[self.webView mainFrame] loadRequest:request];
|
||||
}
|
||||
|
||||
|
||||
- (void)close {
|
||||
[(AtomApp *)NSApp removeController:self];
|
||||
[super close];
|
||||
|
||||
2
Rakefile
2
Rakefile
@@ -8,7 +8,7 @@ task :build do
|
||||
|
||||
dest = File.join(built_dir, contents_dir, "Resources")
|
||||
|
||||
%w( index.html src docs static extensions test vendor ).each do |dir|
|
||||
%w( spec-suite.html index.html src docs static extensions test vendor ).each do |dir|
|
||||
rm_rf File.join(dest, dir)
|
||||
cp_r dir, File.join(dest, dir)
|
||||
end
|
||||
|
||||
1
spec-suite.html
Normal file
1
spec-suite.html
Normal file
@@ -0,0 +1 @@
|
||||
OMG HI
|
||||
Reference in New Issue
Block a user