| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 
 | class:: CocoaDocument
summary:: implements Document functionality
related:: Classes/Document
categories:: Platform>OSX
description::
CocoaDocument implements link::Classes/Document:: functionality for the SuperCollider user interface on Mac OSX.
You could instantiate it e.g. by running code::CocoaDocument.new:: but in order to write platform-independent code you should not do this - simply call code::Document.new:: and this instantiates the correct class for your system.
For examples and method descriptions see link::Classes/Document::.
ClassMethods::
private::initClass, prSetDefaultFont, prSetSyntaxColorTheme, prDefaultUsesAutoInOutdent_, prnumberOfOpen, prGetIndexOfListener
method:: wikiBrowse
If set to code::true::, underlining text will create a wiki link.
argument:: value
An instance of link::Classes/Boolean::. Default value is code::true::.
method:: wikiDir
Get/set the default wiki directory. The default is dependent on link::Classes/Document#implementationClass::.
argument:: path
The file system path to the directory. An instance of link::Classes/String::.
method:: postColor
Get / set the listeners pen color.
argument:: col
An instance of link::Classes/Color::.
discussion::
code::
CocoaDocument.postColor; // returns current post color
CocoaDocument.postColor_(Color.red);
CocoaDocument.postColor_(Color.green);
CocoaDocument.postColor_(Color.blue);
CocoaDocument.postColor_(Color.black);
(
r = Routine({
	10.do({
		Document.postColor_(Color.rand);
		"There is no blue without yellow and without orange.".postln;
		0.5.rand.yield;
	});
	CocoaDocument.postColor_(Color.black);
});
)
r.play;
r.stop;
::
method:: setTheme
Sets the theme for syntax colorization.
argument:: themeName
A link::Classes/Symbol::, defining the name of the theme that you've put into code::Document.themes::.
discussion::
The Document class has a preset theme called code::'default'::, which is set as follows (default SC colors):
code::
themes = (
	default: (
		classColor: Color(0, 0, 0.75, 1),
		textColor: Color(0, 0, 0, 1),
		stringColor: Color(0.375, 0.375, 0.375, 1),
		commentColor: Color(0.75, 0, 0, 1),
		symbolColor: Color(0, 0.45, 0, 1),
		numberColor: Color(0, 0, 0, 1)
	)
);
::
If you want to have your own themes for syntax colorization, you need to put your color set into code::CocoaDocument.themes:: first (preferably in startup.rtf file) and call code::setTheme:: by giving it the name of the theme you've added to "themes" earlier:
code::
//putting a custom color theme into Document.themes
CocoaDocument.themes.put
(\myTheme,
	(
		classColor: Color.new255(53, 74, 187),
		textColor: Color.new255(0, 0, 0),
		stringColor: Color.new255(96, 129, 158),
		commentColor: Color.new255(206, 27, 28),
		symbolColor: Color.new255(57, 154, 20),
		numberColor: Color.new255(157, 80, 65)
	)
);
//and then calling setTheme with the name:
CocoaDocument.setTheme('myTheme');
//to see the current theme:
CocoaDocument.theme;
::
You can switch to the default theme anytime by calling:
code::
CocoaDocument.setTheme('default');
::
Next time you invoke syntaxColorize, the color theme set by setTheme will be used for syntax colorization. If you want to change the background color for the document window and selected text, in order to make them fit with your syntax colorization theme, see the help for the link::Classes/CocoaDocument#background:: and link::Classes/CocoaDocument#selectedBackground:: methods for Document.
InstanceMethods::
private::prUsesAutoInOutdent_, prIsEditable_, prSetTitle, prGetTitle, prGetFileName, prSetFileName, prGetBounds, prSetBounds, prBalanceParens, prclose, prinsertText, prinitByIndex, prGetLastIndex, propen, prinitByString, prSetBackgroundColor, prGetBackgroundColor, prSetSelectedBackgroundColor, prGetSelectedBackgroundColor, prSelectLine, prSetFont
method:: balanceParens
Starting from the current selection, increase the selection until matching parentheses are selected.
argument:: level
Do this as many times to find ever wider brackets. Set to code::inf:: for outmost.
discussion::
code::
((((
CocoaDocument.current.balanceParens(1);
CocoaDocument.current.balanceParens(3);
CocoaDocument.current.balanceParens(inf);
))))
::
method:: background
Get / set the the Document's background color.
argument:: color
An instance of link::Classes/Color::.
discussion::
code::
(
a = Document("background", "'hardly see anything");
a.background_(Color.blue(alpha:0.8)); // notice that alpha controls the window transparency
)
::
method:: stringColor
Gets or sets the string color of a specific range of already printed text. Default is the whole document. To set the listener text color for posting, see: link::Classes/Document#postColor::.
argument:: color
An instance of link::Classes/Color::.
argument:: rangeStart
An link::Classes/Integer::. Default is -1.
argument:: rangeSize
An link::Classes/Integer::. Default value is 0
discussion::
code::
// Select the following code in parentheses and execute it
(
Document.current.stringColor_(Color.rand(0.2, 0.8),
	Document.current.selectedRangeLocation + 13,
	16);
)
// Watch me change color
::
method:: selectedBackground
Gets or sets the document's background color for selected text. Applies to the whole document instance.
argument:: color
An instance of link::Classes/Color::.
discussion::
code::
Document.current.selectedBackground; // returns default color
(
w = Document.new("Test", "Here is a selected text...");
w.selectedBackground_(Color.new255(120, 180, 110));
w.selectRange(10, 13);
)
::
method:: syntaxColorize
Syntax colorize a document.
method:: makeWikiPage
Creates a wiki page.
argument:: wikiWord
An instance of link::Classes/String::. The name of the document.
argument:: extension
An instance of link::Classes/String::. The file extension.
argument:: directory
An instance of link::Classes/String::. The directory in which to save the page.
discussion::
code::
Document.current.makeWikiPage("test1");
::
method:: openWikiPage
Opens/creates a wiki page out of the currently selected text.
 |