Class Index | File Index

Classes


Class eclipse.Editor

A Editor is a user interface for editing text.
Defined in: </shared/eclipse/e4/orion/I201106021400/plugins/org.eclipse.orion.client.editor/web/js/editor.js>.

Class Summary
Constructor Attributes Constructor Name and Description
 
eclipse.Editor(options)
Constructs a new editor.
Field Summary
Field Attributes Field Name and Description
<inner>  
<inner>  
Method Summary
Method Attributes Method Name and Description
 
addEventListener(type, context, func, data)
Adds an event listener to the editor.
 
addRuler(ruler)
Adds a ruler to the editor.
 
convert(rect, from, to)
Converts the given rectangle from one coordinate spaces to another.
 
Destroys the editor.
 
Gives focus to the editor.
 
getActions(defaultAction)
Returns all action names defined in the editor.
 
getBottomIndex(fullyVisible)
Returns the bottom index.
 
Returns the bottom pixel.
 
Returns the caret offset relative to the start of the document.
 
Returns the client area.
 
Returns the horizontal pixel.
 
Returns all the key bindings associated to the given action name.
 
getLineHeight(lineIndex)
Returns the line height for a given line index.
 
getLinePixel(lineIndex)
Returns the top pixel position of a given line index relative to the beginning of the document.
 
Returns the {x, y} pixel location of the top-left corner of the character bounding box at the specified offset in the document.
 
Returns the text model of the editor.
 
Returns the character offset nearest to the given pixel location.
 
Returns the editor selection.
 
getText(start, end)
Returns the text for the given range.
 
getTopIndex(fullyVisible)
Returns the top index.
 
Returns the top pixel.
 
invokeAction(name, defaultAction)
Executes the action handler associated with the given name.
 
redrawLines(startLine, endLine, ruler)
Redraws the text in the given line range.
 
redrawRange(start, end)
Redraws the text in the given range.
 
removeEventListener(type, context, func, data)
Removes an event listener from the editor.
 
removeRuler(ruler)
Removes a ruler from the editor.
 
setAction(name, handler)
Associates an application defined handler to an action name.
 
setCaretOffset(caret, show)
Sets the caret offset relative to the start of the document.
 
Sets the horizontal pixel.
 
setKeyBinding(keyBinding, name)
Associates a key binding with the given action name.
 
setModel(model)
Sets the text model of the editor.
 
setSelection(start, end, show)
Sets the editor selection.
 
setText(text, start, end)
Replaces the text in the given range with the given text.
 
setTopIndex(topIndex)
Sets the top index.
 
setTopPixel(pixel)
Sets the top pixel.
 
Scrolls the selection into view if needed.
Event Summary
Event Attributes Event Name and Description
 
onDestroy(destroyEvent)
This event is sent when the editor has been destroyed.
 
onLineStyle(lineStyleEvent)
This event is sent when the editor needs the style information for a line.
 
onModelChanged(modelChangingEvent)
This event is sent when the text in the model has changed.
 
onModelChanging(modelChangingEvent)
This event is sent when the text in the model is about to change.
 
onModify(modifyEvent)
This event is sent when the editor has changed text in the model.
 
onScroll(scrollEvent)
This event is sent when the editor scrolls vertically or horizontally.
 
onSelection(selectionEvent)
This event is sent when the editor selection has changed.
 
onVerify(verifyEvent)
This event is sent when the editor is about to change text in the model.
Class Detail
eclipse.Editor(options)
Constructs a new editor.
Parameters:
options
the editor options.
{String|DOMElement} options.parent
the parent element for the editor, it can be either a DOM element or an ID for a DOM element.
{eclipse.TextModel} options.model Optional
the text model for the editor. If this options is not set the editor creates an empty eclipse.TextModel.
{Boolean} options.readonly Optional, Default: false
whether or not the editor is read-only.
{Boolean} options.fullSelection Optional, Default: true
whether or not the editor is in full selection mode.
{String|String[]} options.stylesheet Optional
one or more stylesheet URIs for the editor.
{Number} options.tabSize Optional
The number of spaces in a tab.
Field Detail
<inner> EventTable

<inner> Selection
Method Detail
addEventListener(type, context, func, data)
Adds an event listener to the editor.
Parameters:
{String} type
the event type. The supported events are:
  • "Modify" See #onModify
  • "Selection" See #onSelection
  • "Scroll" See #onScroll
  • "Verify" See #onVerify
  • "Destroy" See #onDestroy
  • "LineStyle" See #onLineStyle
  • "ModelChanging" See #onModelChanging
  • "ModelChanged" See #onModelChanged
{Object} context
the context of the function.
{Function} func
the function that will be executed when the event happens. The function should take an event as the first parameter and optional data as the second parameter.
{Object} data Optional
optional data passed to the function.
See:
#removeEventListener

addRuler(ruler)
Adds a ruler to the editor.
Parameters:
{eclipse.Ruler} ruler
the ruler.

convert(rect, from, to)
Converts the given rectangle from one coordinate spaces to another.

The supported coordinate spaces are:

All methods in the editor that take or return a position are in the document coordinate space.

Parameters:
rect
the rectangle to convert.
rect.x
the x of the rectangle.
rect.y
the y of the rectangle.
rect.width
the width of the rectangle.
rect.height
the height of the rectangle.
{String} from
the source coordinate space.
{String} to
the destination coordinate space.
See:
#getLocationAtOffset
#getOffsetAtLocation
#getTopPixel
#setTopPixel

destroy()
Destroys the editor.

Removes the editor from the page and frees all resources created by the editor. Calling this function causes the "Destroy" event to be fire so that all components attached to editor can release their references.

See:
#onDestroy

focus()
Gives focus to the editor.

{String[]} getActions(defaultAction)
Returns all action names defined in the editor.

There are two types of actions, the predefined actions of the editor and the actions added by application code.

The predefined actions are:

Parameters:
{Boolean} defaultAction Optional, Default: false
whether or not the predefined actions are included.
Returns:
{String[]} an array of action names defined in the editor.
See:
#invokeAction
#setAction
#setKeyBinding
#getKeyBindings

{Number} getBottomIndex(fullyVisible)
Returns the bottom index.

The bottom index is the line that is currently at the bottom of the editor. This line may be partially visible depending on the vertical scroll of the editor. The parameter fullyVisible determines whether to return only fully visible lines.

Parameters:
{Boolean} fullyVisible Optional, Default: false
if true, returns the index of the last fully visible line. This parameter is ignored if the editor is not big enough to show one line.
Returns:
{Number} the index of the bottom line.
See:
#getTopIndex
#setTopIndex

{Number} getBottomPixel()
Returns the bottom pixel.

The bottom pixel is the pixel position that is currently at the bottom edge of the editor. This position is relative to the beginning of the document.

Returns:
{Number} the bottom pixel.
See:
#getTopPixel
#setTopPixel
#convert

getCaretOffset()
Returns the caret offset relative to the start of the document.
Returns:
the caret offset relative to the start of the document.
See:
#setCaretOffset
#setSelection
#getSelection

getClientArea()
Returns the client area.

The client area is the portion in pixels of the document that is visible. The client area position is relative to the beginning of the document.

Returns:
the client area rectangle {x, y, width, height}.
See:
#getTopPixel
#getBottomPixel
#getHorizontalPixel
#convert

{Number} getHorizontalPixel()
Returns the horizontal pixel.

The horizontal pixel is the pixel position that is currently at the left edge of the editor. This position is relative to the beginning of the document.

Returns:
{Number} the horizontal pixel.
See:
#setHorizontalPixel
#convert

{eclipse.KeyBinding[]} getKeyBindings(name)
Returns all the key bindings associated to the given action name.
Parameters:
{String} name
the action name.
Returns:
{eclipse.KeyBinding[]} the array of key bindings associated to the given action name.
See:
#setKeyBinding
#setAction

{Number} getLineHeight(lineIndex)
Returns the line height for a given line index. Returns the default line height if the line index is not specified.
Parameters:
{Number} lineIndex Optional
the line index.
Returns:
{Number} the height of the line in pixels.
See:
#getLinePixel

{Number} getLinePixel(lineIndex)
Returns the top pixel position of a given line index relative to the beginning of the document.

Clamps out of range indices.

Parameters:
{Number} lineIndex
the line index.
Returns:
{Number} the pixel position of the line.
See:
#setTopPixel
#convert

getLocationAtOffset(offset)
Returns the {x, y} pixel location of the top-left corner of the character bounding box at the specified offset in the document. The pixel location is relative to the document.

Clamps out of range offsets.

Parameters:
{Number} offset
the character offset
Returns:
the {x, y} pixel location of the given offset.
See:
#getOffsetAtLocation
#convert

{eclipse.TextModel} getModel()
Returns the text model of the editor.
Returns:
{eclipse.TextModel} the text model of the editor.

getOffsetAtLocation(x, y)
Returns the character offset nearest to the given pixel location. The pixel location is relative to the document.
Parameters:
x
the x of the location
y
the y of the location
Returns:
the character offset at the given location.
See:
#getLocationAtOffset

{eclipse.Selection} getSelection()
Returns the editor selection.

The selection is defined by a start and end character offset relative to the document. The character at end offset is not included in the selection.

Returns:
{eclipse.Selection} the editor selection
See:
#setSelection

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

The text does not include the character at the end offset.

Parameters:
{Number} start Optional, Default: 0
the start offset of text range.
{Number} end Optional, Default: char count
the end offset of text range.
See:
#setText

{Number} getTopIndex(fullyVisible)
Returns the top index.

The top index is the line that is currently at the top of the editor. This line may be partially visible depending on the vertical scroll of the editor. The parameter fullyVisible determines whether to return only fully visible lines.

Parameters:
{Boolean} fullyVisible Optional, Default: false
if true, returns the index of the first fully visible line. This parameter is ignored if the editor is not big enough to show one line.
Returns:
{Number} the index of the top line.
See:
#getBottomIndex
#setTopIndex

{Number} getTopPixel()
Returns the top pixel.

The top pixel is the pixel position that is currently at the top edge of the editor. This position is relative to the beginning of the document.

Returns:
{Number} the top pixel.
See:
#getBottomPixel
#setTopPixel
#convert

{Boolean} invokeAction(name, defaultAction)
Executes the action handler associated with the given name.

The application defined action takes precedence over predefined actions unless the defaultAction paramater is true.

If the application defined action returns false, the editor predefined action is executed if present.

Parameters:
{String} name
the action name.
{Boolean} defaultAction Optional
whether to always execute the predefined action.
Returns:
{Boolean} true if the action was executed.
See:
#setAction
#getActions

redrawLines(startLine, endLine, ruler)
Redraws the text in the given line range.

The line at the end index is not redrawn.

Parameters:
{Number} startLine Optional, Default: 0
the start line
{Number} endLine Optional, Default: line count
the end line
ruler

redrawRange(start, end)
Redraws the text in the given range.

The character at the end offset is not redrawn.

Parameters:
{Number} start Optional, Default: 0
the start offset of text range
{Number} end Optional, Default: char count
the end offset of text range

removeEventListener(type, context, func, data)
Removes an event listener from the editor.

All the parameters must be the same ones used to add the listener.

Parameters:
{String} type
the event type.
{Object} context
the context of the function.
{Function} func
the function that will be executed when the event happens.
{Object} data Optional
optional data passed to the function.
See:
#addEventListener

removeRuler(ruler)
Removes a ruler from the editor.
Parameters:
{eclipse.Ruler} ruler
the ruler.

setAction(name, handler)
Associates an application defined handler to an action name.

If the action name is a predefined action, the given handler executes before the default action handler. If the given handler returns true, the default action handler is not called.

Parameters:
{String} name
the action name.
{Function} handler
the action handler.
See:
#getActions
#invokeAction

setCaretOffset(caret, show)
Sets the caret offset relative to the start of the document.
Parameters:
{Number} caret
the caret offset relative to the start of the document.
{Boolean} show Optional, Default: true
if true, the editor will scroll if needed to show the caret location.
See:
#getCaretOffset
#setSelection
#getSelection

setHorizontalPixel(pixel)
Sets the horizontal pixel.

The horizontal pixel is the pixel position that is currently at the left edge of the editor. This position is relative to the beginning of the document.

Parameters:
{Number} pixel
the horizontal pixel.
See:
#getHorizontalPixel
#convert

setKeyBinding(keyBinding, name)
Associates a key binding with the given action name. Any previous association with the specified key binding is overwriten. If the action name is null, the association is removed.
Parameters:
{eclipse.KeyBinding} keyBinding
the key binding
{String} name
the action

setModel(model)
Sets the text model of the editor.
Parameters:
{eclipse.TextModel} model
the text model of the editor.

setSelection(start, end, show)
Sets the editor selection.

The selection is defined by a start and end character offset relative to the document. The character at end offset is not included in the selection.

The caret is always placed at the end offset. The start offset can be greater than the end offset to place the caret at the beginning of the selection.

Clamps out of range offsets.

Parameters:
{Number} start
the start offset of the selection
{Number} end
the end offset of the selection
{Boolean} show Optional, Default: true
if true, the editor will scroll if needed to show the caret location.
See:
#getSelection

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

The character at the end offset is not replaced.

When both start and end parameters are not specified, the editor places the caret at the beginning of the document and scrolls to make it visible.

Parameters:
{String} text
the new text.
{Number} start Optional, Default: 0
the start offset of text range.
{Number} end Optional, Default: char count
the end offset of text range.
See:
#getText

setTopIndex(topIndex)
Sets the top index.

The top index is the line that is currently at the top of the editor. This line may be partially visible depending on the vertical scroll of the editor.

Parameters:
{Number} topIndex
the index of the top line.
See:
#getBottomIndex
#getTopIndex

setTopPixel(pixel)
Sets the top pixel.

The top pixel is the pixel position that is currently at the top edge of the editor. This position is relative to the beginning of the document.

Parameters:
{Number} pixel
the top pixel.
See:
#getBottomPixel
#getTopPixel
#convert

showSelection()
Scrolls the selection into view if needed.
See:
#getSelection
#setSelection
Event Detail
onDestroy(destroyEvent)
This event is sent when the editor has been destroyed.
Parameters:
{eclipse.DestroyEvent} destroyEvent
the event
See:
#destroy

onLineStyle(lineStyleEvent)
This event is sent when the editor needs the style information for a line.
Parameters:
{eclipse.LineStyleEvent} lineStyleEvent
the event

onModelChanged(modelChangingEvent)
This event is sent when the text in the model has changed.
Parameters:
{eclipse.ModelChangingEvent} modelChangingEvent
the event

onModelChanging(modelChangingEvent)
This event is sent when the text in the model is about to change.
Parameters:
{eclipse.ModelChangingEvent} modelChangingEvent
the event

onModify(modifyEvent)
This event is sent when the editor has changed text in the model.

If the text is changed directly through the model API, this event is not sent.

Parameters:
{eclipse.ModifyEvent} modifyEvent
the event

onScroll(scrollEvent)
This event is sent when the editor scrolls vertically or horizontally.
Parameters:
{eclipse.ScrollEvent} scrollEvent
the event

onSelection(selectionEvent)
This event is sent when the editor selection has changed.
Parameters:
{eclipse.SelectionEvent} selectionEvent
the event

onVerify(verifyEvent)
This event is sent when the editor is about to change text in the model.

If the text is changed directly through the model API, this event is not sent.

Listeners are allowed to change these parameters. Setting text to null or undefined stops the change.

Parameters:
{eclipse.VerifyEvent} verifyEvent
the event

Documentation generated by JsDoc Toolkit 2.4.0 on Thu Jun 02 2011 14:09:18 GMT-0400 (EDT)