supernova: c++11 compile fix
[supercollider.git] / Help / GUI / Cocoa-GUI / DocumentAutoCompletion.html
blob4452e8fa5ecabf940536512f4f0eaba0add56a03
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta http-equiv="Content-Style-Type" content="text/css">
6 <title></title>
7 <meta name="Generator" content="Cocoa HTML Writer">
8 <meta name="CocoaVersion" content="949.43">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 23.0px Helvetica}
11 p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
12 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #000000}
15 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #000000; min-height: 14.0px}
16 p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #bf0000}
17 p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #0000bf}
18 p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #007300}
19 p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000; min-height: 12.0px}
20 p.p11 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000}
21 span.s1 {color: #153adf}
22 span.s2 {color: #0000bf}
23 span.s3 {color: #606060}
24 span.s4 {color: #000000}
25 span.s5 {color: #0000ff}
26 span.Apple-tab-span {white-space:pre}
27 </style>
28 </head>
29 <body>
30 <p class="p1"><b>SuperCollider autocompletion</b></p>
31 <p class="p2"><br></p>
32 <p class="p3">The autocompletion feature described in this document is available in the OSX version only. It uses the keyDownAction feature of <a href="../../OSX/CocoaDocument.html"><span class="s1">CocoaDocument</span></a> to intercept keystrokes and open the autocompletion interface when specific characters are typed. That feature is not available in all platforms.</p>
33 <p class="p2"><br></p>
34 <p class="p3">The SCEL interface in Linux has its own autocompletion function, accessed by typing &lt;ESC&gt; &lt;TAB&gt;.</p>
35 <p class="p2"><br></p>
36 <p class="p3">Autocompletion is not available in the Windows version as of this writing.</p>
37 <p class="p2"><br></p>
38 <p class="p3">Another way to get information about classes and methods is the class browser, accessed by calling ".browse" on a class, e.g. <b>Object.browse</b>. The browser is available in the OSX version, as well as any platform where SwingOSC (http://www.sciss.de/swingOSC) is installed.</p>
39 <p class="p2"><br></p>
40 <p class="p4"><b>Usage:</b></p>
41 <p class="p2"><br></p>
42 <p class="p3">To open a text window with the auto-complete feature enabled, execute the following in SuperCollider:</p>
43 <p class="p2"><br></p>
44 <p class="p5"><span class="s2">Document</span>.autoComplete</p>
45 <p class="p2"><br></p>
46 <p class="p3">(ac is a shortcut for Auto-complete, to make it easier to type.)</p>
47 <p class="p2"><br></p>
48 <p class="p3">To open a file by pathname:</p>
49 <p class="p6"><br></p>
50 <p class="p5"><span class="s2">Document</span>.openFileAutoComplete(<span class="s3">"myPath.rtf"</span>);</p>
51 <p class="p7"><span class="s2">Document</span><span class="s4">.openFileAutoComplete(</span><span class="s3">"*.sc"</span><span class="s4">);<span class="Apple-tab-span"> </span></span>// wildcards are supported</p>
52 <p class="p6"><br></p>
53 <p class="p3">To bring up an open-file dialog:</p>
54 <p class="p2"><br></p>
55 <p class="p5"><span class="s2">Document</span>.openAutoComplete</p>
56 <p class="p2"><br></p>
57 <p class="p3">Autocompletion will be integrated more tightly into the code editor.</p>
58 <p class="p2"><br></p>
59 <p class="p4"><b>Summary:</b></p>
60 <p class="p2"><br></p>
61 <p class="p3">While editing code in an auto-complete code window, the following keystrokes initiate special actions:</p>
62 <p class="p2"><br></p>
63 <p class="p3"><b>(</b> -- attempt to match the preceding identifier to method names containing that string, and display a list of methods with their defining classes. Making a selection will insert a method template into your document.</p>
64 <p class="p2"><br></p>
65 <p class="p3">( will also match classnames, with the .new method: Rect( will show you a method template for Rect-*new.</p>
66 <p class="p2"><br></p>
67 <p class="p3"><b>.</b> -- attempt to match the preceding identifier to an exact class name, and present a list of class methods (not instance methods). Your selection will insert a method template into the document.</p>
68 <p class="p2"><br></p>
69 <p class="p3"><b>ctrl-.</b> -- attempt to match the preceding identifier to class names containing the identifier, and present a list of those class names. Your selection will open a class browser. You can navigate through the class tree to find the method you want, and press enter in the method list to insert a method template.</p>
70 <p class="p2"><br></p>
71 <p class="p3"><b>Shortcut in the class browser:</b> type ^ in the method list to go to the superclass. This allows speedier location of methods inherited from superclasses.</p>
72 <p class="p2"><br></p>
73 <p class="p3"><b>Special behavior for ctrl-.</b> -- when you choose a method in a class browser, its class will be compared to the class you chose in the opening list. If the initial class responds to the method, the initial class will be put into the document; otherwise, the class from the class browser.</p>
74 <p class="p2"><br></p>
75 <p class="p4"><b>Feature description:</b></p>
76 <p class="p2"><br></p>
77 <p class="p3">When you type a dot, SuperCollider will to check the previous text to see if it refers to a valid class. If so, a window will be presented with all the class methods (not instance methods) of the class.</p>
78 <p class="p2"><br></p>
79 <p class="p3">So, for example, if you type:</p>
80 <p class="p2"><br></p>
81 <p class="p8">SinOsc<span class="s4">.</span></p>
82 <p class="p2"><br></p>
83 <p class="p3">the window will display the options:</p>
84 <p class="p2"><br></p>
85 <p class="p3">ar(freq, phase, mul, add)</p>
86 <p class="p3">buildSynthDef()</p>
87 <p class="p3">buildSynthDef_()</p>
88 <p class="p3">....</p>
89 <p class="p2"><br></p>
90 <p class="p3">If you type the first few letters into the text box, the list will reduce itself to the matching entries. If you type 'a', then the list will contain only:</p>
91 <p class="p2"><br></p>
92 <p class="p3">ar(freq, phase, mul, add)</p>
93 <p class="p2"><br></p>
94 <p class="p3">Press enter or return, and the method name with all its arguments will be added to your document, leaving the text:</p>
95 <p class="p2"><br></p>
96 <p class="p5"><span class="s2">SinOsc</span>.ar(freq, phase, mul, add)</p>
97 <p class="p2"><br></p>
98 <p class="p3">You can also click on the item you want in the list (or move through the list with the up and down arrow keys), and then press return.</p>
99 <p class="p2"><br></p>
100 <p class="p3">Pressing escape or closing the window will cancel the auto-complete. Text typed into the text box prior to canceling will be added to the document--so, if you keep typing while the box comes up and you want to ignore it, your text will not be lost.</p>
101 <p class="p2"><br></p>
102 <p class="p3">Similar behavior for method names: when you type an open parenthesis '(', SuperCollider will display a list of all classes that define this method. Type the first few letters of the class name (don't forget to capitalize) to choose the right one.</p>
103 <p class="p2"><br></p>
104 <p class="p3">This treatment is necessary because variables in SuperCollider are not typed. If you enter 'func.value(', the text editor has no way to know what kind of object will be contained in func at the time of execution. So, it presents you with all possible options and allows you to choose.</p>
105 <p class="p2"><br></p>
106 <p class="p3"><b>New: </b>The autocompleter now supports partial string matching for methods (triggered by typing open-paren) and classes (not by typing dot, but by typing ctrl-dot). In the case of classes, you will be given a list of classes matching the string typed. After you choose from the list, a full class browser will be opened. When you select a method and press enter, a method template will be dropped into the current document.</p>
107 <p class="p2"><br></p>
108 <p class="p3">Because the class browser does not show methods defined by superclasses, you may press ^ to go to the superclass.</p>
109 <p class="p2"><br></p>
110 <p class="p4"><b>Further configuration:</b></p>
111 <p class="p2"><br></p>
112 <p class="p3">Use the startup file (see <a href="../../Extending and Customizing SC/Using-the-Startup-File.html"><span class="s5">Using-the-Startup-File</span></a>) to define class names and method names to be excluded from the browsers. I like to exclude the most common flow of control mechanisms (while, do, if, etc.).</p>
113 <p class="p2"><br></p>
114 <p class="p9"><span class="s2">AutoCompMethodBrowser</span><span class="s4">.exclude([</span>\if<span class="s4">, </span>\do<span class="s4">, </span>\while<span class="s4">, </span>\loop<span class="s4">, </span>\collect<span class="s4">, </span>\select<span class="s4">, </span>\reject<span class="s4">, </span>\detect<span class="s4">, </span>\add<span class="s4">, </span>\put<span class="s4">, </span>\at<span class="s4">]);</span></p>
115 <p class="p10"><br></p>
116 <p class="p11"><span class="s2">AutoCompClassBrowser</span>.exclude([... list of classes ...]);</p>
117 <p class="p2"><br></p>
118 <p class="p4"><b>Quirks and caveats:</b></p>
119 <p class="p2"><br></p>
120 <p class="p3">The auto complete features will be lost from all documents when recompiling the class library.</p>
121 <p class="p2"><br></p>
122 <p class="p3">The method browser does not handle inheritance. If you're browsing a method like 'add', you won't find Array in the list (but you will find its superclass ArrayedCollection).</p>
123 </body>
124 </html>