1 CocoaDocument : Document {
5 Document.implementationClass = CocoaDocument;
14 if(post.notNil) { post.name_(" post ") }
16 this.setTheme('default');
19 *new { arg title="Untitled", string="", makeListener=false;
20 ^super.prBasicNew.initByString(title, string.asString, makeListener);
25 CocoaDocument.prSetDefaultFont(font);
29 *prSetDefaultFont{|font|
30 _TextWindow_SetDefaultFont
33 *prSetSyntaxColorTheme {|textC, classC, stringC, symbolC, commentC, numberC, specialValsC, specialVarsC, declC, puncC, environC|
34 _TextWindow_SetSyntaxColorTheme
42 _TextWindow_UnfocusedFront
45 alwaysOnTop_{|boolean=true|
46 _TextWindow_AlwaysOnTop
50 _TextWindow_IsAlwaysOnTop
54 _TextWindow_SyntaxColorize
57 selectRange {arg start=0, length=0;
58 _TextWindow_SelectRange
61 editable_{arg abool=true;
63 this.prIsEditable_(abool);
66 _TextWindow_RemoveUndo
70 _TextWindow_SetPromptToSave
74 _TextWindow_PromptToSave
78 _TextWindow_UnderlineSelection
81 balanceParens { arg levels = 1;
82 var prev = this.selectionStart, next;
86 next = this.selectionStart;
87 if(prev == next) { ^this };
91 *postColor_{ arg color;
92 _PostWindow_SetTextColor
102 //private-----------------------------------
104 *prDefaultUsesAutoInOutdent_{|bool|
105 _TextWindow_DefaultUsesAutoInOutdent
108 prUsesAutoInOutdent_{|bool|
109 _TextWindow_UsesAutoInOutdent
112 prIsEditable_{arg editable=true;
113 _TextWindow_SetEditable
115 prSetTitle { arg argName;
117 ^this.primitiveFailed
123 _TextWindow_GetFileName
124 ^this.primitiveFailed
126 prSetFileName {|apath|
127 _TextWindow_SetFileName
129 prGetBounds { arg argBounds;
130 _TextWindow_GetBounds
131 ^this.primitiveFailed
134 prSetBounds { arg argBounds;
135 _TextWindow_SetBounds
136 ^this.primitiveFailed
139 _TextWindow_BalanceParens
143 //if range is -1 apply to whole doc
144 setFont {arg font, rangeStart= -1, rangeSize=100;
145 this.prSetFont(font.asSCFont, rangeStart, rangeSize);
148 prSetFont { arg font, rangeStart, rangeSize;
150 ^this.primitiveFailed
153 setTextColor { arg color, rangeStart = -1, rangeSize = 0;
154 _TextWindow_SetTextColor
161 _TextWindow_SelectedText
163 selectUnderlinedText { arg clickPos;
164 _TextWindow_SelectUnderlinedText
168 linkAtClickPos { arg clickPos;
169 _TextWindow_LinkAtClickPos
173 rangeText { arg rangestart=0, rangesize=1;
174 _TextWindow_TextWithRange
181 prinsertText { arg dataPtr, txt;
182 _TextWindow_InsertText
184 insertTextRange { arg string, rangestart, rangesize;
185 _TextWindow_InsertTextInRange
186 ^this.primitiveFailed
194 _NumberOfOpenTextWindows
196 prinitByIndex { arg idx;
197 _TextWindow_GetByIndex
200 _TextWindow_GetLastIndex
204 propen { arg path, selectionStart=0, selectionLength=0;
207 prinitByString { arg title, str, makeListener;
213 prSetBackgroundColor { arg color;
214 _TextWindow_SetBackgroundColor
216 prGetBackgroundColor { arg color;
217 _TextWindow_GetBackgroundColor
219 prSetSelectedBackgroundColor { arg color;
220 _TextWindow_SetSelectedBackgroundColor
222 prGetSelectedBackgroundColor{ arg color;
223 _TextWindow_GetSelectedBackgroundColor
225 selectedRangeLocation {
226 _TextWindow_GetSelectedRangeLocation
229 _TextWindow_GetSelectedRangeLength
232 prSelectLine { arg line;
233 _TextWindow_SelectLine;
234 ^this.primitiveFailed
237 *prGetIndexOfListener {
238 _TextWindow_GetIndexOfListener
243 if(dataptr.isNil,{^nil});
244 this.background_(Color.white);