Merge branch 'making-things-easy' of github.com:github/atom into making-things-easy

This commit is contained in:
Corey Johnson & Nathan Sobo 2012-09-12 08:34:28 -07:00
commit bda3bcac4e
6 changed files with 100 additions and 35 deletions

View File

@ -1,4 +1,4 @@
require 'fileutils'
require 'timeout'
$ATOM_ARGS = []
@ -9,9 +9,11 @@ desc "Create xcode project from gpy file"
task "create-project" do
`rm -rf atom.xcodeproj`
`python tools/gyp/gyp --depth=. atom.gyp`
`killall -c Xcode 2> /dev/null`
`open atom.xcodeproj` # In order for the xcodebuild to know about the schemes, the project needs to have been opened once. This is xcode bullshit and is a bug on Apple's end (No radar has been file because I have no faith in radar's)
sleep 0 while `xcodebuild -list` =~ /This project contains no schemes./ # Give xcode some time to open
# `killall -c Xcode -9`
# `open atom.xcodeproj` # In order for the xcodebuild to know about the schemes, the project needs to have been opened once. This is xcode bullshit and is a bug on Apple's end (No radar has been file because I have no faith in radar's)
Timeout::timeout(10) do
sleep 0 while `xcodebuild -list` =~ /This project contains no schemes./ # Give xcode some time to open
end
end
desc "Build Atom via `xcodebuild`"
@ -32,9 +34,9 @@ end
desc "Create the Atom.app for distribution"
task :package => :build do
if path = application_path()
FileUtils.rm_rf "pkg"
FileUtils.mkdir_p "pkg"
FileUtils.cp_r path, "pkg/"
rm_rf "pkg"
mkdir_p "pkg"
cp_r path, "pkg/"
`cd pkg && zip -r atom.zip .`
else
exit(1)
@ -44,12 +46,13 @@ end
desc "Creates symlink from `application_path() to /Applications/Atom and creates a CLI at /usr/local/bin/atom"
task :install => :build do
if path = application_path()
FileUtils.ln_sf File.expand_path(path), "/Applications"
ln_sf File.expand_path(path), "/Applications"
usr_bin = "/usr/local/bin"
usr_bin_exists = ENV["PATH"].split(":").include?(usr_bin)
if usr_bin_exists
cli_path = "#{usr_bin}/atom"
`echo '#!/bin/sh\nopen #{path.strip} --args $@' > #{cli_path} && chmod 755 #{cli_path}`
# `echo '#!/bin/sh\n#{path}/Contents/MacOS/Atom $@' > #{cli_path} && chmod 755 #{cli_path}`
else
stderr.puts "ERROR: Did not add cli tool for `atom` because /usr/local/bin does not exist"
end
@ -121,5 +124,5 @@ def application_path
$stderr.puts "Error: No .xcodebuild-info file found. This file is created when the `build` raketask is run"
end
return path
return path.strip()
end

View File

@ -51,7 +51,6 @@
}
- (void)open:(NSString *)path {
NSLog(@"%@", path);
[[AtomWindowController alloc] initWithPath:path];
}
@ -139,6 +138,11 @@
CefShutdown();
}
- (BOOL)applicationShouldHandleReopen:(NSApplication *)application hasVisibleWindows:(BOOL)flag {
NSLog(@"%@", @"OK OK OK");
return YES;
}
# pragma mark CefAppProtocol
- (BOOL)isHandlingSendEvent {

View File

@ -2,27 +2,27 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>atom.icns</string>
<key>CFBundleIdentifier</key>
<string>com.github.atom</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>AtomApp</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>atom.icns</string>
<key>CFBundleIdentifier</key>
<string>com.github.atom</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>AtomApp</string>
</dict>
</plist>

View File

@ -1,16 +1,69 @@
#import "include/cef_application_mac.h"
#import "native/atom_application.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
int main(int argc, char* argv[]) {
@autoreleasepool {
NSString *socketPath = [NSString stringWithFormat:@"/tmp/atom-%d.sock", getuid()];
int fd = socket(AF_UNIX, SOCK_DGRAM, 0);
fcntl(fd, F_SETFD, FD_CLOEXEC);
for (NSRunningApplication *app in [[NSWorkspace sharedWorkspace] runningApplications]) {
BOOL hasSameBundleId = [app.bundleIdentifier isEqualToString:[[NSBundle mainBundle] bundleIdentifier]];
BOOL hasSameProcessesId = app.processIdentifier == [[NSProcessInfo processInfo] processIdentifier];
if (hasSameBundleId && !hasSameProcessesId) {
struct sockaddr_un send_addr;
send_addr.sun_family = AF_UNIX;
strcpy(send_addr.sun_path, [socketPath UTF8String]);
char buf[] = "WE JUMPED THE PROCESS";
if (sendto(fd, buf, sizeof(buf), 0, (sockaddr *)&send_addr, sizeof(send_addr)) < 0) {
NSLog(@"Send failure");
exit(1);
}
exit(0);
}
}
struct sockaddr_un addr;
addr.sun_family = AF_UNIX;
strcpy(addr.sun_path, [socketPath UTF8String]);
unlink([socketPath UTF8String]);
if (bind(fd, (sockaddr*)&addr, sizeof(addr)) < 0) {
perror("ERROR: Binding to socket");
}
else {
NSLog(@"I AM LISTENING");
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^{
char buf[1000];
struct sockaddr_un listen_addr;
listen_addr.sun_family = AF_UNIX;
strcpy(listen_addr.sun_path, [socketPath UTF8String]);
socklen_t listen_addr_length;
if (recvfrom(fd, &buf, sizeof(buf), 0, (sockaddr *)&listen_addr, &listen_addr_length) < 0) {
perror("ERROR: Receiving from socket");
}
else {
NSLog(@"GOOD! Got %s from %s", buf, listen_addr.sun_path);
}
});
}
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
AtomApplication *application = [AtomApplication applicationWithArguments:argv count:argc];
NSString *mainNibName = [infoDictionary objectForKey:@"NSMainNibFile"];
NSNib *mainNib = [[NSNib alloc] initWithNibNamed:mainNibName bundle:[NSBundle mainBundle]];
[mainNib instantiateNibWithOwner:application topLevelObjects:nil];
CefRunMessageLoop();
close(fd);
}
return 0;

View File

@ -18,8 +18,11 @@ class Directory
for path in fs.list(@path)
if fs.isDirectory(path)
directories.push(new Directory(path))
else
else if fs.isFile(path)
files.push(new File(path))
else
console.error "#{path} is neither a file nor a directory."
directories.concat(files)
afterSubscribe: ->

View File

@ -3,8 +3,10 @@
padding: 0;
}
body {
html, body {
font: 16px Inconsolata, Monaco, Courier !important;
width: 100%;
height: 100%;
}
#root-view {