Class Index | File Index

Classes


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/I201107200200/plugins/org.eclipse.orion.client.editor/web/orion/textview/textModel.js>.

Class Summary
Constructor Attributes Constructor Name and Description
 
orion.textview.TextModel(text, lineDelimiter)
Constructs a new TextModel with the given text and default line delimiter.
Method Summary
Method Attributes Method Name and Description
 
addListener(listener)
Adds a listener to the model.
 
Returns the number of characters in the model.
 
getLine(lineIndex, includeDelimiter)
Returns the text of the line at the given index.
 
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(start, removedCharCount, addedCharCount, removedLineCount, addedLineCount)
Notifies all listeners that the text has changed.
 
onChanging(text, start, removedCharCount, addedCharCount, removedLineCount, addedLineCount)
Notifies all listeners that the text is about to change.
 
removeListener(listener)
Removes a listener from the model.
 
setText(text, start, end)
Replaces the text in the given range with the given text.
Class Detail
orion.textview.TextModel(text, lineDelimiter)
Constructs a new TextModel with the given text and default line delimiter.
Parameters:
{String} text Optional, Default: ""
the text that the model will store
{String} lineDelimiter Optional, Default: platform delimiter
the line delimiter used when inserting new lines to the model.
Method Detail
addListener(listener)
Adds a listener to the model.
Parameters:
{Object} listener
the listener to add.
{Function} listener.onChanged Optional
see #onChanged.
{Function} listener.onChanging Optional
see #onChanging.
See:
removeListener

{Number} getCharCount()
Returns the number of characters in the model.
Returns:
{Number} the number of characters in the model.

{String} getLine(lineIndex, includeDelimiter)
Returns the text of the line at the given index.

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

{Number} getLineAtOffset(offset)
Returns the line index at the given character offset.

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.

{Number} getLineCount()
Returns the number of lines in the model.

The model always has at least one line.

Returns:
{Number} the number of lines.

{String} getLineDelimiter()
Returns the line delimiter that is used by the view when inserting new lines. New lines entered using key strokes and paste operations use this line delimiter.
Returns:
{String} the line delimiter that is used by the view when inserting new lines.

{Number} getLineEnd(lineIndex, includeDelimiter)
Returns the end character offset for the given line.

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

{Number} getLineStart(lineIndex)
Returns the start character offset for the given line.

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

getText(start, end)
Returns the text for the given range.

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

onChanged(start, removedCharCount, addedCharCount, removedLineCount, addedLineCount)
Notifies all listeners that the text has changed.

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:
{Number} start
the character offset in the model where the change occurred.
{Number} removedCharCount
the number of characters removed from the model.
{Number} addedCharCount
the number of characters added to the model.
{Number} removedLineCount
the number of lines removed from the model.
{Number} addedLineCount
the number of lines added to the model.

onChanging(text, start, removedCharCount, addedCharCount, removedLineCount, addedLineCount)
Notifies all listeners that the text is about to change.

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:
{String} text
the text that is about to be inserted in the model.
{Number} start
the character offset in the model where the change will occur.
{Number} removedCharCount
the number of characters being removed from the model.
{Number} addedCharCount
the number of characters being added to the model.
{Number} removedLineCount
the number of lines being removed from the model.
{Number} addedLineCount
the number of lines being added to the model.

removeListener(listener)
Removes a listener from the model.
Parameters:
{Object} listener
the listener to remove
See:
#addListener

setText(text, start, end)
Replaces the text in the given range with the given text.

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

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Jul 20 2011 02:04:44 GMT-0400 (EDT)