Merge pull request #506 from andrewcsmith/patch-2
[supercollider.git] / SCClassLibrary / Platform / osx / OSXPlatform.sc
blob7cd62e443ae52292ccc1c96ba7a10d0c360614c4
1 OSXPlatform : UnixPlatform
3         var <>preferencesAction;
4         var <>sleepAction, <>wakeAction, <>isSleeping=false;
6         initPlatform {
7                 super.initPlatform;
8                 recordingsDir = "~/Music/SuperCollider Recordings".standardizePath;
9                 this.declareFeature(\unixPipes); // pipes are possible (can't declare in UnixPlatform since IPhonePlatform is unixy yet can't support pipes)
10                 if (Platform.ideName == "scapp") { this.setDeferredTaskInterval(1/60); }
11         }
13         name { ^\osx }
15         startupFiles {
16                 var filename = "startup.rtf";
17                 var deprecated = [this.systemAppSupportDir +/+ filename, this.userAppSupportDir +/+ filename];
18                 Platform.deprecatedStartupFiles(deprecated);
19                 ^(deprecated ++ super.startupFiles)
20         }
22         startup {
23                 Server.program = "exec %/scsynth".format(String.scDir.shellQuote);
25                 Score.program = Server.program;
27                 if(Platform.ideName == "scapp") {
28                         Document.implementationClass.startup;
29                 };
30                 this.loadStartupFiles;
31                 if(Platform.ideName == "scapp") {
32                         // make server window
33                         Server.internal.makeWindow;
34                         Server.local.makeWindow;
35                 };
36         }
37         shutdown {
38                 HIDDeviceService.releaseDeviceList;
39                 if(Platform.ideName == "scapp"){
40                         CocoaMenuItem.clearCustomItems;
41                 };
42         }
44         // Prefer qt but fall back to cocoa if qt not installed.
45         defaultGUIScheme { if (GUI.get(\qt).notNil) {^\qt} {^\cocoa} }
46         defaultHIDScheme { ^\osx_hid }
48         setDeferredTaskInterval { |interval| _SetDeferredTaskInterval }
50         findHelpFile { | string |
51                 ^string.findHelpFile;
52         }
54         getMouseCoords {
55                 ^this.prGetMouseCoords(Point.new);
56         }
58         prGetMouseCoords {|point|
59                 _Mouse_getCoords
60                 ^this.primitiveFailed
61         }
63         // for now just write syntax colours. Could be other things.
64         writeClientCSS {
65                 var theme, file, string;
66                 theme = Document.theme;
67                 SCDoc.helpTargetDir.mkdir;
68                 file = File.open(SCDoc.helpTargetDir ++ "/frontend.css", "w");
69                 string = ".str { color: %; } /* strings */
70 .kwd { color: %; } /* special values like true, nil.. */
71 .com { color: %; } /* comments */
72 .typ { color: %; } /* class names */
73 .lit { color: %; } /* numbers and character literals */
74 .pun { color: %; } /* punctuation */
75 .pln { color: %; } /* plain text, methods and variable names */
76 .tag { color: %; } /* special variables like super, thisProcess... */
77 .dec { color: %; } /* declarations like var, const... */
78 .atn { color: %; } /* symbols */
79 .atv { color: %; } /* environment vars */".format(
80                         theme.stringColor.hexString,
81                         theme.specialValsColor.hexString,
82                         theme.commentColor.hexString,
83                         theme.classColor.hexString,
84                         theme.numberColor.hexString,
85                         theme.puncColor.hexString,
86                         theme.textColor.hexString,
87                         theme.specialVarsColor.hexString,
88                         theme.declColor.hexString,
89                         theme.symbolColor.hexString,
90                         theme.environColor.hexString
91                 );
92                 file.putString(string);
93                 file.close;
94         }