Class orion.textview.TextModel
The TextModel is an interface that provides text for the view. Applications may implement the TextModel interface to provide a custom store for the view content. The view interacts with its text model in order to access and update the text that is being displayed and edited in the view. This is the default implementation.
See:
orion.textview.TextView
orion.textview.TextView#setModel
Defined in: </shared/eclipse/e4/orion/I201301232230/plugins/org.eclipse.orion.client.editor/web/orion/textview/textModel.js>.
Constructor Attributes | Constructor Name and Description |
---|---|
orion.textview.TextModel(text, lineDelimiter)
Constructs a new TextModel with the given text and default line delimiter.
|
Method Attributes | Method Name and Description |
---|---|
addEventListener(type, listener, useCapture)
Adds an event listener to this event target.
|
|
dispatchEvent(evt)
Dispatches the given event to the listeners added to this event target.
|
|
find(options)
Finds occurrences of a string in the text model.
|
|
Returns the number of characters in the model.
|
|
getLine(lineIndex, includeDelimiter)
Returns the text of the line at the given index.
|
|
getLineAtOffset(offset)
Returns the line index at the given character offset.
|
|
Returns the number of lines in the model.
|
|
Returns the line delimiter that is used by the view
when inserting new lines.
|
|
getLineEnd(lineIndex, includeDelimiter)
Returns the end character offset for the given line.
|
|
getLineStart(lineIndex)
Returns the start character offset for the given line.
|
|
getText(start, end)
Returns the text for the given range.
|
|
onChanged(modelChangedEvent)
Notifies all listeners that the text has changed.
|
|
onChanging(modelChangingEvent)
Notifies all listeners that the text is about to change.
|
|
removeEventListener(type, listener, useCapture)
Removes an event listener from the event target.
|
|
setLineDelimiter(lineDelimiter, all)
Sets the line delimiter that is used by the view
when new lines are inserted in the model due to key
strokes and paste operations.
|
|
setText(text, start, end)
Replaces the text in the given range with the given text.
|
Defined in: </shared/eclipse/e4/orion/I201301232230/plugins/org.eclipse.orion.client.editor/web/orion/textview/eventTarget.js>.
- Parameters:
- {String} type
- The event type.
- {Function|EventListener} listener
- The function or the EventListener that will be executed when the event happens.
- {Boolean} useCapture Optional, Default: false
true
if the listener should be trigged in the capture phase.
- See:
- #removeEventListener
Defined in: </shared/eclipse/e4/orion/I201301232230/plugins/org.eclipse.orion.client.editor/web/orion/textview/eventTarget.js>.
- Parameters:
- {Event} evt
- The event to dispatch.
- Parameters:
- {orion.textview.FindOptions} options
- the search options
- Returns:
- {orion.textview.FindIterator} the find occurrences iterator.
- Returns:
- {Number} the number of characters in the model.
The valid indices are 0 to line count exclusive. Returns null
if the index is out of range.
- Parameters:
- {Number} lineIndex
- the zero based index of the line.
- {Boolean} includeDelimiter Optional, Default: false
- whether or not to include the line delimiter.
- Returns:
- {String} the line text or
null
if out of range.
- See:
- #getLineAtOffset
The valid offsets are 0 to char count inclusive. The line index for
char count is line count - 1
. Returns -1
if
the offset is out of range.
- Parameters:
- {Number} offset
- a character offset.
- Returns:
- {Number} the zero based line index or
-1
if out of range.
The model always has at least one line.
- Returns:
- {Number} the number of lines.
- Returns:
- {String} the line delimiter that is used by the view when inserting new lines.
The end offset is not inclusive. This means that when the line delimiter is included, the offset is either the start offset of the next line or char count. When the line delimiter is not included, the offset is the offset of the line delimiter.
The valid indices are 0 to line count exclusive. Returns -1
if the index is out of range.
- Parameters:
- {Number} lineIndex
- the zero based index of the line.
- {Boolean} includeDelimiter Optional, Default: false
- whether or not to include the line delimiter.
- Returns:
- {Number} the line end offset or
-1
if out of range.
- See:
- #getLineStart
The valid indices are 0 to line count exclusive. Returns -1
if the index is out of range.
- Parameters:
- {Number} lineIndex
- the zero based index of the line.
- Returns:
- {Number} the line start offset or
-1
if out of range.
- See:
- #getLineEnd
The end offset is not inclusive. This means that character at the end offset is not included in the returned text.
- Parameters:
- {Number} start Optional, Default: 0
- the zero based start offset of text range.
- {Number} end Optional, Default: char count
- the zero based end offset of text range.
- See:
- #setText
This notification is intended to be used only by the view. Application clients should use orion.textview.TextView#event:onModelChanged.
NOTE: This method is not meant to called directly by application code. It is called internally by the TextModel as part of the implementation of #setText. This method is included in the public API for documentation purposes and to allow integration with other toolkit frameworks.
- Parameters:
- {orion.textview.ModelChangedEvent} modelChangedEvent
- the changed event
This notification is intended to be used only by the view. Application clients should use orion.textview.TextView#event:onModelChanging.
NOTE: This method is not meant to called directly by application code. It is called internally by the TextModel as part of the implementation of #setText. This method is included in the public API for documentation purposes and to allow integration with other toolkit frameworks.
- Parameters:
- {orion.textview.ModelChangingEvent} modelChangingEvent
- the changing event
All the parameters must be the same ones used to add the listener.
Defined in: </shared/eclipse/e4/orion/I201301232230/plugins/org.eclipse.orion.client.editor/web/orion/textview/eventTarget.js>.
- Parameters:
- {String} type
- The event type
- {Function|EventListener} listener
- The function or the EventListener that will be executed when the event happens.
- {Boolean} useCapture Optional, Default: false
true
if the listener should be trigged in the capture phase.
- See:
- #addEventListener
all
argument is true
.
If lineDelimiter is "auto", the delimiter is computed to be the first delimiter found in the current text. If lineDelimiter is undefined or if there are no delimiters in the current text, the platform delimiter is used.
- Parameters:
- {String} lineDelimiter
- the line delimiter that is used by the view when inserting new lines.
- {Boolean} all Optional, Default: false
- whether or not the delimiter of existing lines are changed.
The end offset is not inclusive. This means that the character at the end offset is not replaced.
The text model must notify the listeners before and after the the text is changed by calling #onChanging and #onChanged respectively.
- Parameters:
- {String} text Optional, Default: ""
- the new text.
- {Number} start Optional, Default: 0
- the zero based start offset of text range.
- {Number} end Optional, Default: char count
- the zero based end offset of text range.
- See:
- #getText