Difference between revisions of "IDE Window: Editor Macros"

From Lazarus wiki
Jump to navigationJump to search
m (Reverted edits by DomingoGP (talk) to last revision by FTurtle)
Tag: Rollback
 
(21 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 +
{{IDE Window: Editor Macros}}
  
= Editor Macros =
+
__TOC__
  
<u>This feature is not available in the released Lazarus 1.0.</u> It is only present in SVN and trunk snapshots.  
+
*<u>Lazarus 1.0 supports only macros entered via the keyboard</u>
<u>The macros via keyboard (as described below) are available in Lazarus 1.0</u>
+
*The Editor Macros window is available in release versions of Lazarus from 1.2.6 onwards. It is <u>not</u> available in the Lazarus 1.0 release.
 +
* See also [[Editor_Macros_PascalScript]]
 +
 
 +
= Editor macros =
  
 
[[File:Editor_macros.png]]
 
[[File:Editor_macros.png]]
  
Lazarus allows you to record any amount of macros. Using the Editor Macro window you can select which macro is currently used. You can also save macros by moving them to the project session, or the IDE config.
+
Lazarus lets you record an unlimited number of macros. The Editor macros dialog allows you to choose which recorded macro is currently played by the dialog's Play button (or by using the default shortcut key combination {{keypress|Shift}}+{{keypress|Ctrl}}+{{keypress|P}} when editing code). Recorded macros can be saved for future reuse by moving them to the project session's saved settings, or to the IDE configuration settings.
 +
 
 +
{{Note|When editing a macro and then '''saving''' it, this saves it to the project (or IDE options) in '''memory'''. You must then save the project to preserve the macro. (Options are saved, for instance, when the IDE is closed). If the project is not saved then changes such as newly recorded or edited macros are lost.}}
  
 
== Display ==
 
== Display ==
  
The macros are displayed in 3 groups:
+
All macros are displayed in one of 3 groupings:
;Recorded: Shows newly recorded macros. These macros are not saved, and will be lost if the IDE is closed
+
;Recorded: This lists newly recorded macros. These macros are not saved, and are lost when the IDE is closed.
;Project: Shows macros that are saved with the project session. Each project can have it's own set of macros.<br/>If the project is configured not to save a session, then macros in this group are not saved, and will be lost when the project is closed.
+
;Project: This lists macros you have opted to be saved with the project session. Each project can have its own set of macros.<br/>Note: If the project is configured not to save a session, then macros in this group are not saved, and will be lost when the project is closed.
;IDE:  Shows macros that are saved with the IDE config. These macros are available to all projects
+
;IDE:  This group lists all macros that will be saved with the IDE configuration settings. These macros are available to all projects.
Macros can be moved between Project and IDE
+
Macros can be moved between Project and IDE using the appropriate button.
  
Macros can have a status icon:
+
Macros may show a status icon:
;[[File:Editor_macros_current.png]]: Current macro. This can be set using the "Select" button. This is the macro that is played, if using the keyboard shortcut.
+
;[[File:Editor_macros_current.png]]: Current macro. This can be set using the "Select" button. This is the macro that will be played when you use the keyboard shortcut (the default is [Shift][Ctrl][P]).
 
;[[File:Editor_macros_rec.png]]: This macro is currently being recorded.
 
;[[File:Editor_macros_rec.png]]: This macro is currently being recorded.
 
;[[File:Editor_macros_play.png]]: This macro is currently playing.
 
;[[File:Editor_macros_play.png]]: This macro is currently playing.
;[[File:Editor_macros_broken.png]]: Broken macro. This indicates that the macro could not be loaded from the config. The macro can not be used. (It will be kept (in it's broken form) in the config)
+
;[[File:Editor_macros_broken.png]]: This macro is broken. This icon indicates that the macro could not be loaded from the configuration file, and so the macro cannot be used. (It will remain untouched in its broken form in the config file).
  
== Interface ==
+
== The Interface of the Editor macros dialog ==
  
# Todo
+
;Select: Sets the <b>current</b> macro which will be used by the keyboard shortcut.<br/>The Play button is not affected by this.
 +
;Rename...: Rename the macro (Macro1, Macro2, etc., the default names assigned by the IDE, are almost completely uninformative, and should be changed to a suitable self-descriptive name such as AlignSelectedLinesAtColon).
 +
;Edit Key: Assign a key-combination for invoking the macro from the keyboard.
 +
;Edit: Edit the macro as source - a new tab is opened in the Source Editor where you can view the naming used by the macro recorder and edit the macro source as needed.
 +
;Delete: Delete the macro.
 +
;Play: Play the selected macro. This is the macro selected by clicking the list. Not the "current" macro.
 +
;Repeat: Sets how often the macro is played when the Play button is pressed. This setting affects only the Play button (the keyboard shortcut invokes only a single execution of the macro).
 +
;Record: Starts the recording of a new macro. <br/>During recording this button doubles as a pause/continue button, allowing you to pause or continue the macro recording.<br/>If anything was recorded, the new macro will be set as the  "current" macro in the Source Editor.
 +
;Stop: This button ends the recording, and also allows you to interrupt and stop repeated play. In certain circumstances, it is possible to stop in the middle of a playing macro.
 +
;Move to: Project/Ide: These two buttons move the selected macro to the indicated group when you want to save the macro for future use. The buttons are enabled or disabled according to the possible action(s).
  
= Using macros by keyboard =
+
= Invoking macros from the keyboard =
  
By Default the following 2 key shortcuts are set up:
+
The Lazarus IDE sets up the following 2 keyboard shortcuts by default:
 
* {{keypress|Shift}}+{{keypress|Ctrl}}+{{keypress|P}} Play the current macro
 
* {{keypress|Shift}}+{{keypress|Ctrl}}+{{keypress|P}} Play the current macro
 
* {{keypress|Shift}}+{{keypress|Ctrl}}+{{keypress|R}} Start/Stop recording a new macro
 
* {{keypress|Shift}}+{{keypress|Ctrl}}+{{keypress|R}} Start/Stop recording a new macro
: During recording, the shortcut for play can be used to pause recording
+
: During recording, the shortcut for Play can be used to Pause recording
 +
 
 +
= Limitations =
 +
 
 +
* A macro can only be recorded from a single editor.<br/>A macro can be played in any editor window afterwards, but only in one editor window at a time.
 +
* Macros only record commands issued by keyboard, and certain menu commands.<br/>Changes caused by mouse buttons or movement (such as moving the caret or selecting text) are [b]not[/b] recorded.
 +
* Macros are restricted to the Editor. You cannot currently record actions made in the Form Designer.
 +
* Sometimes you may be able to record actions apart from the editing of text. However, this is not supported, and playback may not render the desired effects correctly (or at all). E.g. It is possible to record stepping in the debugger (F7,F8,F9), but on playback you may find some of the commands are skipped at random.

Latest revision as of 21:02, 21 August 2020

Deutsch (de) English (en) русский (ru)

  • Lazarus 1.0 supports only macros entered via the keyboard
  • The Editor Macros window is available in release versions of Lazarus from 1.2.6 onwards. It is not available in the Lazarus 1.0 release.
  • See also Editor_Macros_PascalScript

Editor macros

Editor macros.png

Lazarus lets you record an unlimited number of macros. The Editor macros dialog allows you to choose which recorded macro is currently played by the dialog's Play button (or by using the default shortcut key combination Shift+Ctrl+P when editing code). Recorded macros can be saved for future reuse by moving them to the project session's saved settings, or to the IDE configuration settings.

Light bulb  Note: When editing a macro and then saving it, this saves it to the project (or IDE options) in memory. You must then save the project to preserve the macro. (Options are saved, for instance, when the IDE is closed). If the project is not saved then changes such as newly recorded or edited macros are lost.

Display

All macros are displayed in one of 3 groupings:

Recorded
This lists newly recorded macros. These macros are not saved, and are lost when the IDE is closed.
Project
This lists macros you have opted to be saved with the project session. Each project can have its own set of macros.
Note: If the project is configured not to save a session, then macros in this group are not saved, and will be lost when the project is closed.
IDE
This group lists all macros that will be saved with the IDE configuration settings. These macros are available to all projects.

Macros can be moved between Project and IDE using the appropriate button.

Macros may show a status icon:

Editor macros current.png
Current macro. This can be set using the "Select" button. This is the macro that will be played when you use the keyboard shortcut (the default is [Shift][Ctrl][P]).
Editor macros rec.png
This macro is currently being recorded.
Editor macros play.png
This macro is currently playing.
Editor macros broken.png
This macro is broken. This icon indicates that the macro could not be loaded from the configuration file, and so the macro cannot be used. (It will remain untouched in its broken form in the config file).

The Interface of the Editor macros dialog

Select
Sets the current macro which will be used by the keyboard shortcut.
The Play button is not affected by this.
Rename...
Rename the macro (Macro1, Macro2, etc., the default names assigned by the IDE, are almost completely uninformative, and should be changed to a suitable self-descriptive name such as AlignSelectedLinesAtColon).
Edit Key
Assign a key-combination for invoking the macro from the keyboard.
Edit
Edit the macro as source - a new tab is opened in the Source Editor where you can view the naming used by the macro recorder and edit the macro source as needed.
Delete
Delete the macro.
Play
Play the selected macro. This is the macro selected by clicking the list. Not the "current" macro.
Repeat
Sets how often the macro is played when the Play button is pressed. This setting affects only the Play button (the keyboard shortcut invokes only a single execution of the macro).
Record
Starts the recording of a new macro.
During recording this button doubles as a pause/continue button, allowing you to pause or continue the macro recording.
If anything was recorded, the new macro will be set as the "current" macro in the Source Editor.
Stop
This button ends the recording, and also allows you to interrupt and stop repeated play. In certain circumstances, it is possible to stop in the middle of a playing macro.
Move to
Project/Ide: These two buttons move the selected macro to the indicated group when you want to save the macro for future use. The buttons are enabled or disabled according to the possible action(s).

Invoking macros from the keyboard

The Lazarus IDE sets up the following 2 keyboard shortcuts by default:

  • Shift+Ctrl+P Play the current macro
  • Shift+Ctrl+R Start/Stop recording a new macro
During recording, the shortcut for Play can be used to Pause recording

Limitations

  • A macro can only be recorded from a single editor.
    A macro can be played in any editor window afterwards, but only in one editor window at a time.
  • Macros only record commands issued by keyboard, and certain menu commands.
    Changes caused by mouse buttons or movement (such as moving the caret or selecting text) are [b]not[/b] recorded.
  • Macros are restricted to the Editor. You cannot currently record actions made in the Form Designer.
  • Sometimes you may be able to record actions apart from the editing of text. However, this is not supported, and playback may not render the desired effects correctly (or at all). E.g. It is possible to record stepping in the debugger (F7,F8,F9), but on playback you may find some of the commands are skipped at random.