root / tmp / org.txm.practically.rcp / doc / overall.html @ 2399
Historique | Voir | Annoter | Télécharger (6,09 ko)
| 1 | 486 | mdecorde | <html>
|
|---|---|---|---|
| 2 | 486 | mdecorde | <h1>Practically Macro</h1> |
| 3 | 2399 | sjacqu01 | Practically Macro is an attempt to add simple editor scripting to the |
| 4 | 2399 | sjacqu01 | Eclipse platform; it is not an attempt at scripting the Eclipse platform |
| 5 | 2399 | sjacqu01 | in general. I believe that editor scripting, while similar to general |
| 6 | 2399 | sjacqu01 | scripting, is fundamentally a different problem. The intent of this |
| 7 | 2399 | sjacqu01 | plug-in is to enable users to record/create editor macros in a |
| 8 | 2399 | sjacqu01 | lightweight manner that can be used temporarily or easily shared with |
| 9 | 2399 | sjacqu01 | others. I have tried to do this in a way that uses public API and public |
| 10 | 2399 | sjacqu01 | assumptions, and I've mostly been able to do so. In my opinion, every |
| 11 | 2399 | sjacqu01 | character entered or navigation button pressed should generate a command |
| 12 | 2399 | sjacqu01 | that can be recorded. However, Eclipse doesn't generate commands for |
| 13 | 2399 | sjacqu01 | everything, so I've done the best I can. |
| 14 | 486 | mdecorde | |
| 15 | 486 | mdecorde | <h2>Requirements</h2> |
| 16 | 2399 | sjacqu01 | Eclipse 3.4 or greater; will not run correctly at 3.3. Requires the |
| 17 | 2399 | sjacqu01 | workbench. Shouldn't require jdt. |
| 18 | 486 | mdecorde | |
| 19 | 486 | mdecorde | <h2>Recording a macro</h2> |
| 20 | 2399 | sjacqu01 | Start recording a macro by typing Alt+Ctrl+R or clicking the "Record |
| 21 | 2399 | sjacqu01 | Macro" button on the main toolbar. The Record button is only enabled |
| 22 | 2399 | sjacqu01 | when a text editor has input focus. Once record mode is invoked, the |
| 23 | 2399 | sjacqu01 | record button will appear depressed. Actions that will be captured by |
| 24 | 2399 | sjacqu01 | recording a macro are Eclipse commands and keystrokes. Mouse activity is |
| 25 | 2399 | sjacqu01 | not captured and should be avoided in the editor window. Once you are |
| 26 | 2399 | sjacqu01 | done recording a macro, click the "Record Macro" button again. If you |
| 27 | 2399 | sjacqu01 | have recorded any macro contents, a Save dialog will pop up allowing you |
| 28 | 2399 | sjacqu01 | to supply a name/id/description for the macro. You can cancel if you |
| 29 | 2399 | sjacqu01 | don't want to keep the macro. To allow the macro to be persisted across |
| 30 | 2399 | sjacqu01 | Eclipse invocations or to allow mapping the command to a keystroke, you |
| 31 | 2399 | sjacqu01 | must supply an ID. If you only supply a name, the macro can be used |
| 32 | 2399 | sjacqu01 | during the Eclipse session only. You can modify/add an ID later in the |
| 33 | 2399 | sjacqu01 | session. |
| 34 | 486 | mdecorde | |
| 35 | 486 | mdecorde | <h2>Playing a macro</h2> |
| 36 | 2399 | sjacqu01 | To play a macro, use the drop down menu on the "Play Macro" button. You |
| 37 | 2399 | sjacqu01 | can use the "Play command..." button to execute any Eclipse command or |
| 38 | 2399 | sjacqu01 | macro that is already defined. If there are user macros defined with |
| 39 | 2399 | sjacqu01 | ids, they will show up in a menu called "Macros". Only the last few will |
| 40 | 2399 | sjacqu01 | be available, and they will be ordered by last used time. If there are |
| 41 | 2399 | sjacqu01 | commands that do not have associated ids, they will show up in the |
| 42 | 2399 | sjacqu01 | submenu named "Temporary Macros", ordered by last used time. After you |
| 43 | 2399 | sjacqu01 | have execute a macro, clicking the Play button will execute the last |
| 44 | 2399 | sjacqu01 | executed macro. |
| 45 | 486 | mdecorde | |
| 46 | 486 | mdecorde | <h2>Gotchas</h2> |
| 47 | 2399 | sjacqu01 | This plug-in is built on top of the Eclipse platform. Unfortunately, the |
| 48 | 2399 | sjacqu01 | Eclipse command structure is not designed with macro recording in mind. |
| 49 | 2399 | sjacqu01 | What this means is that not all commands are recordable, and some |
| 50 | 2399 | sjacqu01 | behavior may be a little sketchy. However, you can edit a macro after |
| 51 | 2399 | sjacqu01 | recording, so you should be able to patch up behavior that isn't |
| 52 | 2399 | sjacqu01 | desirable. The lack of an official Eclipse strategy means that there is |
| 53 | 2399 | sjacqu01 | no guide to what commands should be recordable, so I don't impose any |
| 54 | 2399 | sjacqu01 | artificial limitations. |
| 55 | 2399 | sjacqu01 | <br> Here are some types of actions that make sense to record as
|
| 56 | 2399 | sjacqu01 | part of a macro: |
| 57 | 2399 | sjacqu01 | <br>
|
| 58 | 2399 | sjacqu01 | <ul>typing characters (see note below)
|
| 59 | 2399 | sjacqu01 | </ul>
|
| 60 | 2399 | sjacqu01 | <ul>navigation characters (ex. arrows, page down)
|
| 61 | 2399 | sjacqu01 | </ul>
|
| 62 | 2399 | sjacqu01 | <ul>find dialog (I've supplied my own since the standard dialog
|
| 63 | 2399 | sjacqu01 | isn't public) |
| 64 | 2399 | sjacqu01 | </ul>
|
| 65 | 2399 | sjacqu01 | <ul>incremental find (with some hacking)
|
| 66 | 2399 | sjacqu01 | </ul>
|
| 67 | 2399 | sjacqu01 | <ul>previously recorded macros
|
| 68 | 2399 | sjacqu01 | </ul>
|
| 69 | 2399 | sjacqu01 | <ul>other commands that don't pop up dialogs (ex. file save, find
|
| 70 | 2399 | sjacqu01 | next, organize imports, toggle insert mode) |
| 71 | 2399 | sjacqu01 | </ul>
|
| 72 | 2399 | sjacqu01 | <br> Here are some types of actions that almost certainly won't
|
| 73 | 2399 | sjacqu01 | work correctly: |
| 74 | 2399 | sjacqu01 | <br>
|
| 75 | 2399 | sjacqu01 | <ul>Commands that bring up dialogs (ex. Go to line)
|
| 76 | 2399 | sjacqu01 | </ul>
|
| 77 | 2399 | sjacqu01 | <ul>Wizards and other dialogs (ex. Open File)
|
| 78 | 2399 | sjacqu01 | </ul>
|
| 79 | 2399 | sjacqu01 | <ul>ctrl+space intellisense
|
| 80 | 2399 | sjacqu01 | </ul>
|
| 81 | 2399 | sjacqu01 | <ul>invoking code templates like "foreach"
|
| 82 | 2399 | sjacqu01 | </ul>
|
| 83 | 486 | mdecorde | |
| 84 | 486 | mdecorde | <h3>Special notes</h3> |
| 85 | 2399 | sjacqu01 | Certain keystrokes are handled specially by the language editor. |
| 86 | 2399 | sjacqu01 | However, these editors don't generate commands associated with their |
| 87 | 2399 | sjacqu01 | behavior, so they are difficult to interpret. For example, in a Java |
| 88 | 2399 | sjacqu01 | file, if you type in a '<', a '>' will be inserted and the cursor will |
| 89 | 2399 | sjacqu01 | be placed between the two symbols. Also, the editor is put into a |
| 90 | 2399 | sjacqu01 | special edit mode so that if you backspace, both characters are deleted. |
| 91 | 2399 | sjacqu01 | However, there is no set of commands generated that accomplishes these |
| 92 | 2399 | sjacqu01 | tasks. Instead, the editor document captures the initial '<' via a
|
| 93 | 2399 | sjacqu01 | VerifyKeyListener and then does the inserts and sets the mode directly |
| 94 | 2399 | sjacqu01 | on the document. Therefore, if you have this setting ("Automatically
|
| 95 | 2399 | sjacqu01 | Close") turned on and type a '<', then the macro will not have any
|
| 96 | 2399 | sjacqu01 | commands corresponding to some of these operations. You can edit the |
| 97 | 2399 | sjacqu01 | macro afterward, but that may be inconvenient. I've added another mode |
| 98 | 2399 | sjacqu01 | on the Options page that records keys as raw key events and plays them |
| 99 | 2399 | sjacqu01 | back. This preserves the behavior of special characters like '<', but is
|
| 100 | 2399 | sjacqu01 | more difficult to edit and may not be sharable with users on other |
| 101 | 2399 | sjacqu01 | platforms. |
| 102 | 2399 | sjacqu01 | <br>
|
| 103 | 2399 | sjacqu01 | <bold>In general, I recommend running in 'Command' mode and
|
| 104 | 2399 | sjacqu01 | 'typing through' special keystroke modes while recording a macro.</bold>
|
| 105 | 486 | mdecorde | |
| 106 | 486 | mdecorde | <h2>Editing macros</h2> |
| 107 | 2399 | sjacqu01 | You can edit macros you have recorded via the |
| 108 | 2399 | sjacqu01 | Window->Preferences->PracticallyMacro Options->Editor Macro Definitions |
| 109 | 2399 | sjacqu01 | page. From this page, you can delete existing macros or edit macros. |
| 110 | 2399 | sjacqu01 | Select a macro and click the Edit... button. From the edit dialog, you |
| 111 | 2399 | sjacqu01 | can reorder commands in the macro, remove commands, add new commands, |
| 112 | 2399 | sjacqu01 | and edit commands that have data associated with them (ex. the Find |
| 113 | 2399 | sjacqu01 | command). The Edit dialog also allows you to add a new macro id to a |
| 114 | 2399 | sjacqu01 | command that didn't previously have an associated id (thus turning it |
| 115 | 2399 | sjacqu01 | into a persistent command), or alter the id of an existing command. |
| 116 | 486 | mdecorde | |
| 117 | 486 | mdecorde | <h2>Sharing macros</h2> |
| 118 | 2399 | sjacqu01 | From the Editor Macro Definitions page you can export or import macros. |
| 119 | 2399 | sjacqu01 | Macros exported to a file can be imported via the import dialog into |
| 120 | 2399 | sjacqu01 | another eclipse (with the Practically Macro plugins installed, as well |
| 121 | 2399 | sjacqu01 | as any required plugins/commands). |
| 122 | 486 | mdecorde | |
| 123 | 486 | mdecorde | <h2>Scripting</h2> |
| 124 | 2399 | sjacqu01 | Macro scripting is provided by plugins via an extension point. See the |
| 125 | 2399 | sjacqu01 | help for different script types on pref or edit pages for those plugins. |
| 126 | 2399 | sjacqu01 | There is no innate scripting provided by the base Practically Macro |
| 127 | 2399 | sjacqu01 | plugin, but there is a default beanshell plugin paired with the main |
| 128 | 2399 | sjacqu01 | plugin. |
| 129 | 486 | mdecorde | </html> |