orion.edit.highlighter | ||
---|---|---|
![]() |
![]() |
|
orion.edit.editor | orion.edit.model |
The orion.edit.highlighter
service contributes syntax highlighting rules to the editor. A highlighter service may provide highlighting in one of two ways:
The service also provides a list of content types. When the editor opens a file of a registered content type, the provider is invoked (using one of the two methods described above) to obtain the styling.
NOTE: The "highlighter" API is experimental and subject to change in future versions.
Implementations of orion.edit.highlighter
whose
type attribute is "highlighter", must define the following method:
When this provider's type is "grammar", no service methods are defined. In other words, the provider is purely declarative.
Implementations of orion.edit.highlighter
must define the following attributes:
String
What kind of highlight provider is being registered. Allowed values are "grammar"
and "highlighter"
. Future versions may support more.Array
An array of
Content Type IDs that this provider will be used for.
Object
Optional. When the
type of this provider is "grammar", this attribute holds an object giving the grammar to be used to assign style classes. This object is a JavaScript equivalent of the format described
here.
When the
type of the provider is "highlighter", the provider must independently listen to changes in the Orion text editor by registering with the orion.edit.model
service, and calculate the necessary highlighting information in response to the changes. Whenever highlighting information is available, the provider must dispatch an event of type "orion.edit.highlighter.styleReady"
containing the styles. The event will be used by the Orion editor to apply styles to the file being displayed.
orion.editor.StyleReadyEvent
. Consult its entry there for detailed information.When the type of the provider is "grammar", the provider dispatches no service events.
var provider = new eclipse.PluginProvider(); provider.registerServiceProvider("orion.edit.highlighter", { // "grammar" provider is purely declarative. No service methods. }, { type : "grammar", contentType: "text/html", grammar: { patterns: [ { begin: "<!--", end: "-->", captures: { "0": "punctuation.definition.comment.html" }, contentName: "comment.block.html" } ] } }); provider.connect();
The above example provides a grammar to be used for HTML files. It will assign the CSS class punctuation-definition-comment-html
to the <!--
and -->
delimiters, and assign the CSS class comment-block-html
to the text inside the delimiters. Consult
this reference for a full description of the grammar format.
(Note that some aspects of the grammar format are not supported. See orion.editor.TextMateStyler
in the Client API reference for a detailed explanation.)
See the source code of the orion-codemirror plugin.
![]() |
![]() |
![]() |
orion.edit.editor | orion.edit.model |