Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Orion/Documentation/Developer Guide/Plugging into the editor"
(→orion.edit.command) |
(→Example) |
||
Line 25: | Line 25: | ||
:An optional key binding for the command | :An optional key binding for the command | ||
− | == | + | == Examples == |
+ | |||
+ | The following simple example just converts the selected text to upper case: | ||
+ | |||
+ | <pre> | ||
+ | var provider = new eclipse.PluginProvider(); | ||
+ | provider.registerServiceProvider("orion.edit.command", { | ||
+ | run : function(text) { | ||
+ | return text.toUpperCase(); | ||
+ | } | ||
+ | }, { | ||
+ | name : "UPPERCASE", | ||
+ | img : "/images/gear.gif", | ||
+ | key : [ "u", true ] | ||
+ | }); | ||
+ | provider.connect(); | ||
+ | </pre> | ||
= orion.edit.contentAssist = | = orion.edit.contentAssist = |
Revision as of 14:53, 14 June 2011
Contents
Overview of contributing services to the Orion editor
The built Orion editor defines a number of services for customizing its appearance and behavior. These services will typically be defined by a plug-in providing editing functionality for different programming languages or file extensions. This section will outline the services that are available for editor customization.
orion.edit.command
The orion.edit.command service is the simplest kind of editor extension. A command service simply provides a function that takes some text as input, performs some operation or transformation on the text, and returns a new text value. The command can also optionally receive and return selection information for changing the editor selection.
Service methods
Implementations of orion.edit.command must define the following function:
- run(selectedText, text, selection)
- selectedText is a string containing the text that is currently selected in the editor. The text argument provides the entire editor buffer. The selection argument is a selection object with start and end fields.
Service attributes
Implementations of orion.edit.command may define the following attributes:
- img
- The URL of an icon to associate with the command
- name
- The command text show to the user
- key
- An optional key binding for the command
Examples
The following simple example just converts the selected text to upper case:
var provider = new eclipse.PluginProvider(); provider.registerServiceProvider("orion.edit.command", { run : function(text) { return text.toUpperCase(); } }, { name : "UPPERCASE", img : "/images/gear.gif", key : [ "u", true ] }); provider.connect();