3 var recvOSCfunc, prRecvOSCFunc;
6 // proof-of-concept: the interpreter can set this variable when executing code in a file
7 // should be nil most of the time
10 var didWarnOverwrite = false;
11 // setup the platform first so that class initializers can call platform methods.
12 // create the platform, then intialize it so that initPlatform can call methods
13 // that depend on thisProcess.platform methods.
14 platform = this.platformClass.new;
15 platform.initPlatform;
19 // set the 's' interpreter variable to the default server.
20 interpreter.s = Server.default;
21 GUI.fromID( this.platform.defaultGUIScheme );
22 GeneralHID.fromID( this.platform.defaultHIDScheme );
23 this.platform.startup;
25 openPorts = Set[NetAddr.langPort];
27 ("Welcome to SuperCollider %.".format(Main.version)
28 + (Platform.ideName.switch(
29 "scvim", {"For help type :SChelp."},
30 "scel", {"For help type C-c C-y."},
31 "sced", {"For help type ctrl-U."},
32 "scapp", {"For help type cmd-d."},
33 "scqt", {"For help press %.".format(if(this.platform.name==\osx,"Cmd-D","Ctrl-D"))}
36 osx: "For help type cmd-d.",
37 linux: "For help type ctrl-c ctrl-h (Emacs) or :SChelp (vim) or ctrl-U (sced/gedit).",
38 windows: "For help press F1.",
45 Main.overwriteMsg.split(Char.nl).drop(-1).collect(_.split(Char.tab)).do {|x|
46 if(x[2].beginsWith(Platform.classLibraryDir) and: {x[1].contains(""+/+"SystemOverwrites"+/+"").not}
48 warn("Extension in '%' overwrites % in main class library.".format(x[1],x[0]));
49 didWarnOverwrite = true;
52 if(didWarnOverwrite) {
53 inform("\nIntentional overwrites must be put in a 'SystemOverwrites' subfolder.")
57 shutdown { // at recompile, quit
59 this.platform.shutdown;
63 run { // used to be called by command-R, customisation now via CocoaMenuItem
64 //interpreter.interpretPrintCmdLine;
67 stop { // called by command-.
71 hardStop { // called by command alt dot
75 recvOSCmessage { arg time, replyAddr, recvPort, msg;
76 // this method is called when an OSC message is received.
77 recvOSCfunc.value(time, replyAddr, msg);
78 prRecvOSCFunc.value(msg, time, replyAddr, recvPort); // same order as OSCFunc
79 OSCresponder.respond(time, replyAddr, msg);
82 recvOSCbundle { arg time, replyAddr, recvPort ... msgs;
83 // this method is called when an OSC bundle is received.
85 this.recvOSCmessage(time, replyAddr, recvPort, msg);
89 addOSCRecvFunc { |func| prRecvOSCFunc = prRecvOSCFunc.addFunc(func) }
91 removeOSCRecvFunc { |func| prRecvOSCFunc = prRecvOSCFunc.removeFunc(func) }
93 replaceOSCRecvFunc { |func, newFunc| prRecvOSCFunc = prRecvOSCFunc.replaceFunc(func, newFunc) }
95 openPorts { ^openPorts.copy } // don't allow the Set to be modified from the outside
97 openUDPPort {|portNum|
99 if(openPorts.includes(portNum), {^true});
100 result = this.prOpenUDPPort(portNum);
101 if(result, { openPorts = openPorts.add(portNum); });
105 prOpenUDPPort {|portNum|
112 win = SCWindow("construction");
117 // override in platform specific extension
124 ^argv ?? { argv = this.prArgv }
128 HelpBrowser.openBrowsePage;
131 HelpBrowser.openSearchPage(this.getCurrentSelection);
134 HelpBrowser.openHelpFor(this.getCurrentSelection);
138 var string, class, method, words;
139 string = interpreter.cmdLine;
140 class = string.asSymbol.asClass;
141 (class ? Object).browse;
144 *version {^[this.scVersionMajor, ".", this.scVersionMinor, this.scVersionPostfix].join}
146 *versionAtLeast { |maj, min|
147 ^if((maj==this.scVersionMajor) and:{min.notNil}){
148 this.scVersionMinor >= min
150 this.scVersionMajor >= maj
154 *versionAtMost { |maj, min|
155 ^if((maj==this.scVersionMajor) and:{min.notNil}){
156 this.scVersionMinor <= min
158 this.scVersionMajor <= maj
164 ^this.primitiveFailed
173 recompile { platform.recompile }
175 escapeWindow { platform.escapeWindow }
177 exitFullScreen { platform.exitFullScreen }
179 setDeferredTaskInterval { |interval| platform.setDeferredTaskInterval(interval) }
181 *overwriteMsg { _MainOverwriteMsg ^this.primitiveFailed }
186 var <ownerClass, <selector, <activePath, <overriddenPath;
188 *new { arg ownerClass, selector, activePath, overriddenPath;
189 ^super.newCopyArgs(ownerClass, selector, activePath, overriddenPath)
192 *fromLine { arg string;
193 var parts = string.split(Char.tab);
195 #class, selector = parts[0].split($:);
196 ^this.new(class.asSymbol.asClass, selector, parts[1], parts[2])
200 var path2 = if(overriddenPath.beginsWith("/Common")) {
201 Platform.classLibraryDir +/+ overriddenPath
202 } { overriddenPath };
203 activePath.openTextFile;
207 *simplifyPath { arg path;
208 var extDir, sysExtDir, quarkDir;
209 extDir = Platform.userExtensionDir;
210 sysExtDir = Platform.systemExtensionDir;
211 quarkDir = LocalQuarks.globalPath;
212 path = path.replace("'" ++ extDir, "Platform.userExtensionDir ++ '");
213 path = path.replace("'" ++ sysExtDir, "Platform.systemExtensionDir ++ '");
214 path = path.replace("'" ++ quarkDir, "LocalQuarks.globalPath ++ '");
220 var msg = Main.overwriteMsg.drop(-1); // drop last newline
221 var lines = msg.split(Char.nl);
222 ^lines.collect { |line| this.fromLine(line) };
225 *printAll { arg simplifyPaths = true;
227 var classes = all.collect(_.ownerClass).as(Set);
228 if(all.isEmpty) { "There are no overwritten methods in class library".postln; ^this };
229 ("Overwritten methods in class library:".underlined ++ "\n\n").post;
231 class.asString.underlined.postln;
232 all.select { |x| x.ownerClass == class }.do { |x|
233 var activePath = x.activePath;
234 var overriddenPath = x.overriddenPath;
236 activePath = this.simplifyPath(x.activePath);
237 overriddenPath = this.simplifyPath(x.overriddenPath);
239 ("\t" ++ x.ownerClass.name ++ ":" ++ x.selector).postln;
240 ("\t\t" ++ activePath).postln;
241 ("\t\t" ++ overriddenPath).postln;
249 var classes = all.collect(_.ownerClass).as(Set);
250 if(all.isEmpty) { "There are no overwritten methods in class library".postln; ^this };
251 ("Overwritten methods in class library:".underlined ++ "\n").post;
253 all.select { |x| x.ownerClass == class }.collect { |x| x.selector }.as(Set).do { |x|
254 postf("\t%:%\n", class, x);