3 summary:: A view displaying editable formatted text
8 TextView consists of an area where strong::multi-line text:: can be typed in and edited.
10 Using the view's methods, the text can be formatted: different strong::font:: and strong::text color:: can be applied to parts of the text. Text can also be inserted, removed, and selected programmatically.
12 The view can strong::open text documents:: and load from them both strong::plain text::, as well as formatted text in strong::HTML::, although it can not save the text back to files. However, you can get the contents of the view using the link::#-string:: method and then implement saving on your own, but the -string method will only return plain text, regardless of how the contents of the view are formatted.
14 note:: strong::Cocoa GUI:: can also load files in the strong::Rich Text Format::. ::
24 SUBSECTION:: Text and Formatting
27 Opens a file at code::path:: and loads text from it.
29 The file can be in plain text or HTML (or RTF, in Cocoa GUI) format. Note however that saving formatted text in the view is not supported.
31 If loading the text from the file succeeds, it will replace any current contents of the view.
37 The entire displayed contents of the view, as plain text.
39 Setting this variable will replace any current contents of the view.
45 Inserts the code::string:: at code::rangeStart:: position, replacing code::rangeSize:: amount of following characters. If code::rangeSize:: is 0, the text will be inserted without any characters being removed.
48 A String - the text to insert.
50 An Integer position within the text, in characters.
52 An Integer amount of characters.
55 Applies the code::font:: to code::rangeSize:: amount of characters following the code::rangeStart:: position.
58 A Font to apply to the desired range of text.
60 An Integer position within the text, in characters.
62 An Integer amount of characters.
64 METHOD:: setStringColor
65 Applies the code::color:: to code::rangeSize:: amount of characters following the code::rangeStart:: position.
68 A Color to apply to the desired range of text.
70 An Integer position within the text, in characters.
72 An Integer amount of characters.
74 METHOD:: syntaxColorize
75 Applies colors to text throughout the entire contents of the view, according to the SuperCollider language syntax highlighting scheme.
80 SUBSECTION:: Text Selection
82 METHOD:: selectedString
83 The plain text contained in the current selection.
86 A String. Setting this variable will replace text in the selection with the argument, or do nothing if there is no selection.
88 A String. If no text is currently selected, an empty String is returned.
91 METHOD:: selectionStart
92 The starting position of the selection. If no text is selected this variable represents the cursor position.
95 An Integer position within the text, in characters.
97 METHOD:: selectionSize
98 The size of the current selection.
101 An Integer amount of characters - 0 if no text is selected.
105 note:: Not available in strong::Cocoa GUI::. ::
107 Selects code::size:: amount of characters following the code::start:: position. The cursor will remain at the end of the new selection.
110 An Integer position within the text, in characters.
112 An Integer amount of characters.
117 SUBSECTION:: Appearance
120 The default font of the entire text. This font applies to any text to which a font has not been applied using link::#-setFont::.
126 The default color of the entire text. This color applies to any text to which a color has not been applied using link::#-setStringColor::.
129 The width of tab characters as they are displayed.
134 SUBSECTION:: Interaction
137 Whether the contents of the view are editable, i.e. the text can be typed in and deleted by the user.
142 METHOD:: enterInterpretsSelection
143 Whether the selection will be interpreted and invoked as SuperCollider code when Ctrl/Cmd/Shift + Enter key combination is pressed.
145 Defaults to code::false::.
150 METHOD:: usesTabToFocusNextView
151 Whether the tab key will - instead of inserting a tab character into the text - switch focus to the next view (as usual for other views).
153 Defaults to code::false::.
158 METHOD:: hasHorizontalScroller
159 Whether the horizontal scroller is shown.
161 Note that if link::#-autohidesScrollers:: is code::true:: the scroller may be hidden despite this variable being set to code::true::. Since the TextView typically wraps text into the next line when a line reaches the edge of the view, the horizontal scroller may never be shown, unless link::#-autohidesScrollers:: is code::false::.
163 Defaults to code::true::.
168 METHOD:: hasVerticalScroller
169 Whether the vertical scroller is shown.
171 Note that if link::#-autohidesScrollers:: is code::true:: the scroller may be hidden despite this variable being set to code::true::.
173 Defaults to code::true::.
178 METHOD:: autohidesScrollers
179 Whether each of the scrollers will be automatically hidden if there is no use for it, i.e. the content is not scrollable in the direction of the scroller.
181 If link::#-hasHorizontalScroller:: or link::#-hasVerticalScroller:: is code::false::, the respective scroller will always be hidden, regardless of this variable.
183 Defaults to code::true::.
190 SUBSECTION:: Drag and Drop
192 note:: Default drag-and-drop behavior of TextView is not defined in standard SC methods (see link::Classes/View#subclassing::), but in the view implementation instead (except for link::#-defaultGetDrag:: in Qt GUI). It may or may not be overridable by adding your own handlers (see link::Classes/View#drag_and_drop::), depending on the GUI kit in use.
195 Dragging from TextView will give the selected text in a String as drag data, while dropping will accept any object and insert it link::Classes/Object#-asString#as String:: at the drop location.
197 You can also drag files from outside SuperCollider onto a TextView, and it will insert their URLs at the drop location.
199 METHOD:: defaultGetDrag
200 note:: Only present in strong::Qt GUI:: ::
203 The link::#-selectedString::.