Added CocoaMenuItem's in SC. Also can now use CMD-j to open class files directly in TextMate

This commit is contained in:
rob 2009-01-03 18:11:29 +00:00
parent 3f6f2f101b
commit 5270149cb6
2 changed files with 52 additions and 5 deletions

View File

@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>saveActiveFile</string>
<string>nop</string>
<key>command</key>
<string>require_cmd sc3c
sc3c -k</string>
@ -14,7 +14,7 @@ sc3c -k</string>
<key>name</key>
<string>Recompile class library</string>
<key>output</key>
<string>discard</string>
<string>showAsTooltip</string>
<key>scope</key>
<string>source.supercollider</string>
<key>uuid</key>

51
TextMate.sc Normal file → Executable file
View File

@ -1,5 +1,28 @@
// http://github.com/rfwatson/sc3ctrl
TextMate {
classvar menu, <openClassInTextMate;
*initClass {
var opt;
menu = CocoaMenuItem(nil, 7, "TextMate", true);
opt = CocoaMenuItem(menu, 0, "TextMate to front", false) {
"osascript << END
tell application \"TextMate\" to activate
END
".unixCmd(postOutput: false)
};
opt.setShortCut("T");
openClassInTextMate = CocoaMenuItem(menu, 1, "Open class files in TextMate", false) { |item|
item.state = item.state.not;
};
openClassInTextMate.state = true;
openClassInTextMate.setShortCut("j", true, true);
}
}
// http://github.com/rfwatson/sc3ctrl
SC3Controller {
classvar nodes;
@ -35,7 +58,31 @@ SC3Controller {
nodes.add(node);
node = OSCresponderNode(nil, '/sc3ctrl/class') { |t, r, msg|
{ msg[1].asString.interpret.openCodeFile }.defer
// TM version only
var klass = msg[1].asString;
var allClasses = Class.allClasses.collect(_.asString);
{
if(TextMate.openClassInTextMate.state) {
if(allClasses.detect{ |str| str == klass }.notNil) { // .includes doesn't work?
var fname = klass.interpret.filenameSymbol;
var cmd = "grep -nh \"^" ++ klass ++ "\" \"" ++ fname ++ "\" > /tmp/grepout.tmp";
cmd.unixCmd(postOutput: false, action: {
File.use("/tmp/grepout.tmp", "r") { |f|
var content = f.readAllString;
var split = content.split($:);
if("^[0-9]+$".matchRegexp(split.first.asString)) {
("mate -l" ++ split.first + "\"" ++ fname ++ "\"").postln.unixCmd(postOutput: false);
} {
("mate" + fname).unixCmd(postOutput: false);
}
};
});
}
} { // open in SC.app
klass.interpret.openCodeFile;
};
}.defer
}.add;
nodes.add(node);