Permalink
Browse files

Merge branch 'master' of github.com:topfunky/PeepOpen-EditorSupport

  • Loading branch information...
2 parents eb34fa9 + d14eb5b commit 789d4b33c805c5cfd7ff9b02a37a37eab8ea54a7 @topfunky committed Nov 10, 2011
View
61 PeepOpen-bbedit/PeepOpen.applescript
@@ -0,0 +1,61 @@
+-- PeepOpen support for BBEdit
+-- Launches PeepOpen for either the current project directory,
+-- first project file, or the current file.
+
+set _theFile to missing value
+
+tell application "BBEdit"
+ if (count of text windows) > 0 then
+ -- Get the first text window. This will return any window that can
+ -- contain a text document (standalone window, project window, etc.)
+ -- and skips over Find windows, Scratchpads, and whatnot
+ set _firstTextWindow to text window 1
+
+ if (class of _firstTextWindow is project window) then
+ set _projectDocument to project document of _firstTextWindow
+ if (on disk of _projectDocument) then
+ set _theProjectDir to file of _projectDocument
+
+ tell application "Finder"
+ set _theFile to container of _theProjectDir
+ end tell
+ else
+ -- Shipping versions of BBEdit don't provide direct access
+ -- to the Instaproject root, so fake it by asking for
+ -- the first node from the project list
+ set _theFile to item 1 of _projectDocument
+ end if
+ else if (class of _firstTextWindow is text window) then
+ if (on disk of document of _firstTextWindow) then
+ set _theFile to file of document of _firstTextWindow
+ end if
+ end if
+ end if
+end tell
+
+if _theFile is equal to missing value then
+ -- No base file found for reference
+ -- Signal error by beep and end
+ beep
+else
+ tell application "Finder"
+ -- To use this path as a hunk of a URL, we need to encode it.
+ -- Ask the Finder to give back a URL, and then extract the
+ -- salient text out of it
+ set _url to URL of _theFile
+ end tell
+
+ -- Separate the path from the URL scheme,
+ -- and eat the "localhost" portion as well
+ set _originalDelimiters to AppleScript's text item delimiters
+ set AppleScript's text item delimiters to {"file://localhost"}
+ set _chunks to (every text item in (_url as text)) as list
+ set AppleScript's text item delimiters to _originalDelimiters
+ set _fullPath to item 2 of _chunks
+
+ -- Construct the PeepOpen URL
+ set _peepOpenURL to "peepopen://" & _fullPath & "?editor=BBEdit"
+
+ -- Launch PeepOpen
+ open location _peepOpenURL
+end if
View
17 PeepOpen-bbedit/README.md
@@ -17,13 +17,30 @@ To run the install:
rake bbedit # Install BBEdit script
rake textwrangler # Install TextWrangler script
+## Installation
+
+ mkdir -p ~/Library/Application\ Support/BBEdit/Scripts/PeepOpen
+ cp PeepOpen.applescript ~/Library/Application\ Support/BBEdit/Scripts/PeepOpen/.
+
To add a shortcut key:
Window -> Palettes -> Scripts
+
Select PeepOpen and click Set Key ...
Enter a shortcut key combination (recommend Command + Option + T)
## Credits
+=======
+ Select PeepOpen -> Peep Open and click Set Key ...
+ Enter a shortcut key combination (recommend Command + Option + T)
+
+## PeepOpen Preferences
+
+To help find the root of a project, you can add BBEdit Project Documents to the Project Root Pattern:
+ ^(\.git|\.hg|Rakefile|Makefile|README\.?.*|build\.xml|.*\.xcodeproj|.*\.bbprojectd)$
+
+
+## Credit
Thanks to Bare Bones Software, Inc. for the initial AppleScript code.
View
4 PeepOpen-tmplugin/Info.plist
@@ -19,9 +19,9 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>1</string>
+ <string>1.1</string>
<key>CFBundleShortVersionString</key>
- <string>1.0</string>
+ <string>1.1</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
View
22 PeepOpen-tmplugin/PeepOpen.m
@@ -3,7 +3,7 @@
// PeepOpen
//
// Created by Pieter Noordhuis on 6/2/10.
-//
+// Updated by Philip Schalm on 13/9/11.
#import "PeepOpen.h"
@@ -27,7 +27,7 @@ @interface OakProjectController (PeepOpen) @end
@implementation OakProjectController (PeepOpen)
- (void)goToFile:(id)sender
{
- NSString *projectDir;
+ NSString *projectDir = NULL;
OakProjectController *project = NULL;
// First try to find a window with a project and get the projectDirectory
@@ -41,13 +41,25 @@ - (void)goToFile:(id)sender
}
if (project != NULL) {
- projectDir = [project projectDirectory];
+ if (!project->isScratchProject && [project->rootItems count] > 0) {
+ // Pull the project directory from the first root item
+ NSDictionary *firstItem = [project->rootItems objectAtIndex:0];
+ if ([project->rootItems count] == 1) {
+ projectDir = [firstItem valueForKey:@"sourceDirectory"];
+ } else {
+ projectDir = [[firstItem valueForKey:@"sourceDirectory"] stringByDeletingLastPathComponent];
+ }
+ }
+ if (NULL == projectDir)
+ projectDir = [project projectDirectory];
}
else if ([[currentDocument valueForKey:@"filename"] length] > 0) {
projectDir = [currentDocument valueForKey:@"filename"];
}
-
- NSString *projectURLString = [NSString stringWithFormat:@"peepopen://%@?editor=TextMate", projectDir];
+
+
+ NSString *projectURLString = [NSString stringWithFormat:@"peepopen://%@?editor=TextMate",
+ [projectDir stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSURL *url = [NSURL URLWithString:projectURLString];
NSLog(@"PeepOpen: Opening URL %@", [url absoluteString]);
[[NSWorkspace sharedWorkspace] openURL:url];
View
1 PeepOpen-tmplugin/PeepOpen.xcodeproj/project.pbxproj
@@ -146,6 +146,7 @@
isa = PBXProject;
buildConfigurationList = 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "PeepOpen" */;
compatibilityVersion = "Xcode 3.1";
+ developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,
View
31 PeepOpen-tmplugin/peepopen-tmplugin.tmproj
@@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>currentDocument</key>
- <string>PeepOpen.h</string>
+ <string>PeepOpen.m</string>
<key>documents</key>
<array>
<dict>
@@ -26,15 +26,15 @@
<key>filename</key>
<string>PeepOpen.h</string>
<key>lastUsed</key>
- <date>2011-01-17T15:44:20Z</date>
- <key>selected</key>
- <true/>
+ <date>2011-11-10T01:09:07Z</date>
</dict>
<dict>
<key>filename</key>
<string>PeepOpen.m</string>
<key>lastUsed</key>
- <date>2011-01-17T15:44:20Z</date>
+ <date>2011-11-10T01:09:11Z</date>
+ <key>selected</key>
+ <true/>
</dict>
<dict>
<key>name</key>
@@ -51,6 +51,8 @@
<dict>
<key>filename</key>
<string>TextMate.h</string>
+ <key>lastUsed</key>
+ <date>2011-11-10T01:09:11Z</date>
</dict>
<dict>
<key>filename</key>
@@ -105,15 +107,30 @@
<key>firstVisibleLine</key>
<integer>0</integer>
</dict>
+ <key>TextMate.h</key>
+ <dict>
+ <key>caret</key>
+ <dict>
+ <key>column</key>
+ <integer>0</integer>
+ <key>line</key>
+ <integer>0</integer>
+ </dict>
+ <key>firstVisibleColumn</key>
+ <integer>0</integer>
+ <key>firstVisibleLine</key>
+ <integer>0</integer>
+ </dict>
</dict>
<key>openDocuments</key>
<array>
<string>PeepOpen.h</string>
+ <string>TextMate.h</string>
<string>PeepOpen.m</string>
</array>
<key>showFileHierarchyDrawer</key>
- <true/>
+ <false/>
<key>windowFrame</key>
- <string>{{525, 4}, {940, 1078}}</string>
+ <string>{{525, 0}, {940, 1028}}</string>
</dict>
</plist>
View
2 vim-peepopen/plugin/peepopen.vim
@@ -26,7 +26,7 @@ set cpo&vim
function s:LaunchPeepOpenViaVim()
let cwd = getcwd()
- silent exe "!open 'peepopen://" . shellescape(cwd) . "?editor=MacVim'"
+ silent exe "!open \"peepopen://" . shellescape(cwd) . "?editor=MacVim\""
endfunction
command! PeepOpen :call <SID>LaunchPeepOpenViaVim()

0 comments on commit 789d4b3

Please sign in to comment.