Class Index | File Index

Classes


Class orion.mirror.ModeApplier

Driver for CodeMirror modes.
Defined in: </jobs/genie.orion/orion-client-stable/workspace/bundles/org.eclipse.orion.client.editor/web/orion/editor/mirror.js>.

Class Summary
Constructor Attributes Constructor Name and Description
 
orion.mirror.ModeApplier(model, mirror, options)
A ModeApplier listens to text changes on a orion.editor.TextModel and drives a CodeMirror mode to calculate highlighting in response to the change.
Method Summary
Method Attributes Method Name and Description
 
addEventListener(type, listener, useCapture)
Adds an event listener to this event target.
 
Deactivates this ModeApplier and removes its listeners.
 
Dispatches the given event to the listeners added to this event target.
 
getLineStyle(lineIndex)
 
 
getState(lineIndex)
Returns the state we can use for parsing from the start of the lineIndexth line.
 
highlight(startLine, endLine, partial)
Highlights the given range of lines.
 
highlightLater(startLine)
Schedules a job that will begin highlighting from startLine.
 
highlightLine(lineIndex, line, state)
Highlights a single line.
 
Called when some highlighting has been performed.
 
removeEventListener(type, listener, useCapture)
Removes an event listener from the event target.
 
setMode(modeSpec, highlightImmediately)
Sets the CodeMirror mode to be used for highlighting.
 
toStyleRangesAndErrors(style, lineIndex)
Converts a MirrorLineStyle to a orion.editor.StyleRange[].
Event Summary
Event Attributes Event Name and Description
 
HighlightEvent(start, end)
Dispatched when the ModeApplier has updated the highlight info for a region of the file.
Class Detail
orion.mirror.ModeApplier(model, mirror, options)
A ModeApplier listens to text changes on a orion.editor.TextModel and drives a CodeMirror mode to calculate highlighting in response to the change. Clients can use the highlighting information to style a orion.editor.TextView.

After a change is made to the orion.editor.TextModel, ModeApplier immediately updates the highlighting information for a small portion of the file around where the change occurred. Successive portions of the file are updated by short jobs that run periodically to avoid slowing down the rest of the application.

A #event:HighlightEvent event is dispatched every time the ModeApplier updates highlighting information for a portion of the file. The event contains information about which lines were highlighted. The style for any highlighted line can be obtained by calling #getLineStyle.

Parameters:
{orion.editor.TextModel} model
The text model to listen to.
{orion.mirror.Mirror} mirror
The orion.mirror.Mirror to use for loading modes.
{Object} options Optional
Method Detail
addEventListener(type, listener, useCapture)
Adds an event listener to this event target.
Defined in: </jobs/genie.orion/orion-client-stable/workspace/bundles/org.eclipse.orion.client.editor/web/orion/editor/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:
orion.editor.EventTarget#removeEventListener

destroy()
Deactivates this ModeApplier and removes its listeners.

dispatchEvent(evt)
Dispatches the given event to the listeners added to this event target.
Defined in: </jobs/genie.orion/orion-client-stable/workspace/bundles/org.eclipse.orion.client.editor/web/orion/editor/eventTarget.js>.
Parameters:
{Event} evt
The event to dispatch.

{orion.mirror.MirrorLineStyle} getLineStyle(lineIndex)
Parameters:
{Number} lineIndex
Returns:
{orion.mirror.MirrorLineStyle}

{orion.mirror.MirrorLineStyle[]} getLineStyles()
Returns:
{orion.mirror.MirrorLineStyle[]}

{Object} getState(lineIndex)
Returns the state we can use for parsing from the start of the lineIndexth line.
Parameters:
{Number} lineIndex
Returns:
{Object} The state. This object is safe to mutate.

highlight(startLine, endLine, partial)
Highlights the given range of lines.
Parameters:
{Number} startLine Optional
{Number} endLine Optional
{Boolean} partial Optional, Default: false
If true, this function is assumed to be running as part of a larger operation, and will not dispatch a #event:HighlightEvent.

highlightLater(startLine)
Schedules a job that will begin highlighting from startLine. The job runs for a short amount of time, after which it dispatches a #event:HighlightEvent indicating its progress, and yields. Follow-up jobs are scheduled automatically if there's more highlighting to be done.
Parameters:
{Number} startLine

highlightLine(lineIndex, line, state)
Highlights a single line.
Parameters:
{Number} lineIndex
{Object} line
{Object} state
The state to use for parsing from the start of the line.

onHighlightDone()
Called when some highlighting has been performed. Dispatches a #event:HighlightEvent.

removeEventListener(type, listener, useCapture)
Removes an event listener from the event target.

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


Defined in: </jobs/genie.orion/orion-client-stable/workspace/bundles/org.eclipse.orion.client.editor/web/orion/editor/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:
orion.editor.EventTarget#addEventListener

setMode(modeSpec, highlightImmediately)
Sets the CodeMirror mode to be used for highlighting. The mode must be registered with the orion.mirror.Mirror that this ModeApplier was created with. (The methods orion.mirror.Mirror#defineMode and orion.mirror.Mirror#defineMIME can be used to register a mode with a Mirror.)
Parameters:
{String} modeSpec
Mode name or MIME type.
{Boolean} highlightImmediately Optional, Default: false

{Array} toStyleRangesAndErrors(style, lineIndex)
Converts a MirrorLineStyle to a orion.editor.StyleRange[].
Parameters:
{orion.mirror.MirrorLineStyle} style
The line style to convert.
{Number} lineIndex Optional
The line index of the line having the given style. If omitted, the returned orion.editor.StyleRange[] objects will have offsets relative to the line, not the document.
Returns:
{Array} An array of 2 elements. The first element is an orion.editor.StyleRange[] giving the styles for the line. The second element is an orion.editor.StyleRange[] containing only those elements of the first array that represent syntax errors. (By CodeMirror convention, anything assigned the "cm-error" tag is assumed to be an error).

Event Detail
HighlightEvent(start, end)
Dispatched when the ModeApplier has updated the highlight info for a region of the file.
Parameters:
{Number} start
The starting line index of the highlighted region.
{Number} end
The ending line index of the highlighted region.

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Jan 18 2017 12:15:12 GMT-0500 (EST)