Class orion.mirror.ModeApplier
Driver for CodeMirror modes.
Defined in: </shared/eclipse/e4/orion/I201404012230/bundles/org.eclipse.orion.client.editor/web/orion/editor/mirror.js>.
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 Attributes | Method Name and Description |
---|---|
addEventListener(type, listener, useCapture)
Adds an event listener to this event target.
|
|
destroy()
Deactivates this ModeApplier and removes its listeners.
|
|
dispatchEvent(evt)
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
lineIndex th 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 Attributes | Event Name and Description |
---|---|
HighlightEvent(start, end)
Dispatched when the ModeApplier has updated the highlight info for a region of the file.
|
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
Defined in: </shared/eclipse/e4/orion/I201404012230/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.
Defined in: </shared/eclipse/e4/orion/I201404012230/bundles/org.eclipse.orion.client.editor/web/orion/editor/eventTarget.js>.
- Parameters:
- {Event} evt
- The event to dispatch.
- Parameters:
- {Number} lineIndex
- Returns:
- {orion.mirror.MirrorLineStyle}
- Returns:
- {orion.mirror.MirrorLineStyle[]}
lineIndex
th line.
- Parameters:
- {Number} lineIndex
- Returns:
- {Object} The state. This object is safe to mutate.
- 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.
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
- Parameters:
- {Number} lineIndex
- {Object} line
- {Object} state
- The state to use for parsing from the start of the line.
All the parameters must be the same ones used to add the listener.
Defined in: </shared/eclipse/e4/orion/I201404012230/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.
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
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).
- Parameters:
- {Number} start
- The starting line index of the highlighted region.
- {Number} end
- The ending line index of the highlighted region.