1 // class extensions needed for autocomplete
4 getIdentifierCoordFromEnd { |endPos|
5 var origpos, pos, chartemp, id;
6 pos = (origpos = endPos ? this.selectionStart) - 1;
8 { (chartemp = this.string(pos, 1)[0]).isAlphaNum or: (chartemp == $_) } }
12 ^[pos+1, origpos-pos-1]
15 *allowAutoComp { ^true } // maybe you want to turn off the IDE features
18 this.globalKeyDownAction = this.autoCompleteKeyAction;
22 ^Document.new.autoComplete;
25 autoComplete { // enable ide for this document
26 Document.allowAutoComp.if({
27 keyDownAction = Document.autoCompleteKeyAction;
31 *autoCompleteKeyAction {
32 ^{ |doc, char, modifiers, keycode|
35 (char == 40 and: (modifiers.bitAnd(131072) > 0)).if({
36 #start, size = doc.getIdentifierCoordFromEnd;
37 AutoCompMethodBrowser(start, size, doc)
40 #start, size = doc.getIdentifierCoordFromEnd;
41 AutoCompClassBrowser(start, size, doc)
43 (keycode == 15 and: (modifiers.bitAnd(262144) > 0)).if({
44 #start, size = doc.getIdentifierCoordFromEnd;
45 AutoCompClassSearch(start, size, doc)
52 *openFileAutoComplete { arg path; // open a file by path
54 path.pathMatch.do({ |p|
55 Document.open(p).autoComplete;
59 *openAutoComplete { // open a file by opendialog
60 File.openDialog("Choose the codefile to open", { |path|
61 this.openFileAutoComplete(path);
69 this.isMetaClass.if({ ^this },{ ^this.class });
74 argList { arg skipThis = true;
76 (skipThis and: (argNames.size <= 1)).not.if({ str = "(" }, { str = "" });
78 // i > 0 if including "this", i > 1 if not
79 (i > (skipThis.binaryValue)).if({ str = str ++ ", " });
80 (skipThis.not and: (i == 0)).if({ str = str ++ "a_" ++ ownerClass.name });
81 (i > 0).if({ str = str ++ a });
83 ^(str.size > 0).if({ str ++ ")" }, { str });
88 isAlphaNum { ^false } // error protection in getIdCoords