SuperCollider autocompletion v0.3
To open a text window with the auto-complete feature enabled, execute the following in SuperCollider:
(ac is a shortcut for Auto-complete, to make it easier to type.)
To open a file by pathname:
Document.openFileAutoComplete("*.sc"); // wildcards are supported
To bring up an open-file dialog:
Autocompletion will be integrated more tightly into the code editor.
While editing code in an auto-complete code window, the following keystrokes initiate special actions:
( -- 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.
( will also match classnames, with the .new method: Rect( will show you a method template for Rect-*new.
. -- 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.
ctrl-. -- 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.
Shortcut in the class browser: type ^ in the method list to go to the superclass. This allows speedier location of methods inherited from superclasses.
Special behavior for ctrl-. -- 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.
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.
So, for example, if you type:
the window will display the options:
ar(freq, phase, mul, add)
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:
ar(freq, phase, mul, add)
Press enter or return, and the method name with all its arguments will be added to your document, leaving the text:
SinOsc.ar(freq, phase, mul, add)
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.
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.
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.
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.
New: 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.
Because the class browser does not show methods defined by superclasses, you may press ^ to go to the superclass.
Place the startup.rtf file in a folder called scwork in your home user directory. You can 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.).
Quirks and caveats:
The auto complete features will be lost from all documents when recompiling the class library.
Because of the way the document class works, the identifiers will not be extracted correctly if the cursor is at the very end of the document. You should leave a couple of empty lines below what you're typing for the feature to work.
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).
Comments or questions to email@example.com, please. No SPAM!Berlin: clubs bars cafes nightlife going out