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" + Main.version
28 ++ (Platform.ideName.switch(
29 "scvim", {", type :SChelp for help"},
30 "scel", {", type C-c C-y for help"},
31 "sced", {", type ctrl-U for help"},
32 "scapp", {", type cmd-d for help"}
35 osx: ", type cmd-d for help",
36 linux: ", for help type ctrl-c ctrl-h (Emacs) or :SChelp (vim) or ctrl-U (sced/gedit)",
37 windows: ", press F1 for help",
44 Main.overwriteMsg.split(Char.nl).drop(-1).collect(_.split(Char.tab)).do {|x|
45 if(x[2].beginsWith(Platform.classLibraryDir) and: {x[1].contains(""+/+"SystemOverwrites"+/+"").not}
47 warn("Extension in '%' overwrites % in main class library.".format(x[1],x[0]));
48 didWarnOverwrite = true;
51 if(didWarnOverwrite) {
52 inform("\nIntentional overwrites must be put in a 'SystemOverwrites' subfolder.")
56 shutdown { // at recompile, quit
58 this.platform.shutdown;
62 run { // used to be called by command-R, customisation now via CocoaMenuItem
63 //interpreter.interpretPrintCmdLine;
66 stop { // called by command-.
70 hardStop { // called by command alt dot
74 recvOSCmessage { arg time, replyAddr, recvPort, msg;
75 // this method is called when an OSC message is received.
76 recvOSCfunc.value(time, replyAddr, msg);
77 prRecvOSCFunc.value(msg, time, replyAddr, recvPort); // same order as OSCFunc
78 OSCresponder.respond(time, replyAddr, msg);
81 recvOSCbundle { arg time, replyAddr, recvPort ... msgs;
82 // this method is called when an OSC bundle is received.
84 this.recvOSCmessage(time, replyAddr, recvPort, msg);
88 addOSCRecvFunc { |func| prRecvOSCFunc = prRecvOSCFunc.addFunc(func) }
90 removeOSCRecvFunc { |func| prRecvOSCFunc = prRecvOSCFunc.removeFunc(func) }
92 replaceOSCRecvFunc { |func, newFunc| prRecvOSCFunc = prRecvOSCFunc.replaceFunc(func, newFunc) }
94 openPorts { ^openPorts.copy } // don't allow the Set to be modified from the outside
96 openUDPPort {|portNum|
98 if(openPorts.includes(portNum), {^true});
99 result = this.prOpenUDPPort(portNum);
100 if(result, { openPorts = openPorts.add(portNum); });
104 prOpenUDPPort {|portNum|
111 win = SCWindow("construction");
116 // override in platform specific extension
123 ^argv ?? { argv = this.prArgv }
127 HelpBrowser.openBrowsePage;
130 HelpBrowser.openSearchPage(this.getCurrentSelection);
133 HelpBrowser.openHelpFor(this.getCurrentSelection);
137 var string, class, method, words;
138 string = interpreter.cmdLine;
139 class = string.asSymbol.asClass;
140 (class ? Object).browse;
143 *version {^[this.scVersionMajor, ".", this.scVersionMinor, this.scVersionPostfix].join}
145 *versionAtLeast { |maj, min|
146 ^if((maj==this.scVersionMajor) and:{min.notNil}){
147 this.scVersionMinor >= min
149 this.scVersionMajor >= maj
153 *versionAtMost { |maj, min|
154 ^if((maj==this.scVersionMajor) and:{min.notNil}){
155 this.scVersionMinor <= min
157 this.scVersionMajor <= maj
163 ^this.primitiveFailed
172 recompile { platform.recompile }
174 escapeWindow { platform.escapeWindow }
176 exitFullScreen { platform.exitFullScreen }
178 setDeferredTaskInterval { |interval| platform.setDeferredTaskInterval(interval) }
180 *overwriteMsg { _MainOverwriteMsg ^this.primitiveFailed }
185 var <ownerClass, <selector, <activePath, <overriddenPath;
187 *new { arg ownerClass, selector, activePath, overriddenPath;
188 ^super.newCopyArgs(ownerClass, selector, activePath, overriddenPath)
191 *fromLine { arg string;
192 var parts = string.split(Char.tab);
194 #class, selector = parts[0].split($:);
195 ^this.new(class.asSymbol.asClass, selector, parts[1], parts[2])
199 var path2 = if(overriddenPath.beginsWith("/Common")) {
200 Platform.classLibraryDir +/+ overriddenPath
201 } { overriddenPath };
202 activePath.openTextFile;
206 *simplifyPath { arg path;
207 var extDir, sysExtDir, quarkDir;
208 extDir = Platform.userExtensionDir;
209 sysExtDir = Platform.systemExtensionDir;
210 quarkDir = LocalQuarks.globalPath;
211 path = path.replace("'" ++ extDir, "Platform.userExtensionDir ++ '");
212 path = path.replace("'" ++ sysExtDir, "Platform.systemExtensionDir ++ '");
213 path = path.replace("'" ++ quarkDir, "LocalQuarks.globalPath ++ '");
219 var msg = Main.overwriteMsg.drop(-1); // drop last newline
220 var lines = msg.split(Char.nl);
221 ^lines.collect { |line| this.fromLine(line) };
224 *printAll { arg simplifyPaths = true;
226 var classes = all.collect(_.ownerClass).as(Set);
227 if(all.isEmpty) { "There are no overwritten methods in class library".postln; ^this };
228 ("Overwritten methods in class library:".underlined ++ "\n\n").post;
230 class.asString.underlined.postln;
231 all.select { |x| x.ownerClass == class }.do { |x|
232 var activePath = x.activePath;
233 var overriddenPath = x.overriddenPath;
235 activePath = this.simplifyPath(x.activePath);
236 overriddenPath = this.simplifyPath(x.overriddenPath);
238 ("\t" ++ x.ownerClass.name ++ ":" ++ x.selector).postln;
239 ("\t\t" ++ activePath).postln;
240 ("\t\t" ++ overriddenPath).postln;
248 var classes = all.collect(_.ownerClass).as(Set);
249 if(all.isEmpty) { "There are no overwritten methods in class library".postln; ^this };
250 ("Overwritten methods in class library:".underlined ++ "\n").post;
252 all.select { |x| x.ownerClass == class }.collect { |x| x.selector }.as(Set).do { |x|
253 postf("\t%:%\n", class, x);