Sign in Join
Wiki copytemporary

Editor Macros PascalScript: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## General
22
33The [[PascalScript]] macro functionality is available in Lazarus 1.1 and later. To use the feature you have to install the package EditorMacroScript, which includes the [[Pascal Script]] package. Pascal Script is provided by REM Objects. A minimum package is provided with the Lazarus 1.1 distribution.
44
55## Availability
66
77This functionality is only available on selected platforms/architectures:
88
99- Windows
1010 - 32/64bit Intel/AMD
1111- Linux
1212 - 32/64bit Intel/AMD
1313- Mac
1414 - 32(/maybe 64)bit Intel/AMD
1515 - 32bit PPC
1616
1717## Simple actions
1818
1919All simple Keyboard actions are represented as follows:
2020
2121ecLeft;
2222Move Caret one to the left (in the editor that invoked the macro)
2323
2424ecChar('a');
2525Inserts an 'a'
2626
2727See the unit SynEditKeyCmds in package [[SynEdit]], and IDECommands in IDEIntf for a full list. Or use the Recorder to get the names of actions.
2828
2929## Functions
3030
3131``` pascal
3232 Function MessageDlg( const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint ): Integer;
3333 Function MessageDlgPos( const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint; X, Y: Integer): Integer;
3434 Function MessageDlgPosHelp( const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint; X, Y: Integer; const HelpFileName: string): Integer;
3535 Procedure ShowMessage( const Msg: string );
3636 Procedure ShowMessagePos( const Msg: string; X, Y Integer );
3737 Function InputBox( const ACaption, APrompt, ADefault: string): string;
3838 Function InputQuery( const ACaption, APrompt: string; var Value: string): Boolean;
3939```
4040
4141## Objects provided
4242
4343Scripts can refer to the invoking SynEdit via the identifier "Caller".
4444
4545### Caller: TSynEdit
4646
4747The following methods and properties are available:
4848
4949Caret
5050
5151``` pascal
5252 property CaretX: Integer;
5353 property CaretY: Integer;
5454 property CaretXY: TPoint;
5555 property LogicalCaretXY: TPoint;
5656 property LogicalCaretX: Integer;
5757 procedure MoveCaretIgnoreEOL(const NewCaret: TPoint);
5858 procedure MoveLogicalCaretIgnoreEOL(const NewLogCaret: TPoint);
5959```
6060
6161Selection
6262
6363``` pascal
6464 property BlockBegin: TPoint;
6565 property BlockEnd: TPoint;
6666 property SelAvail: Boolean; // read only
6767 property SelText: string;
6868 property SelectionMode: TSynSelectionMode;
6969 procedure ClearSelection;
7070 procedure SelectAll;
7171 procedure SelectToBrace;
7272 procedure SelectWord;
7373 procedure SelectLine(WithLeadSpaces: Boolean);
7474 procedure SelectParagraph;
7575```
7676
7777Search/Replace
7878
7979``` pascal
8080 function SearchReplace(const ASearch, AReplace: string; AOptions: TSynSearchOptions): integer;
8181 function SearchReplaceEx(const ASearch, AReplace: string; AOptions: TSynSearchOptions; AStart: TPoint): integer;
8282
8383 TSynSearchOptions = set of
8484 ( ssoMatchCase, ssoWholeWord,
8585 ssoBackwards,
8686 ssoEntireScope, ssoSelectedOnly, // Default is From Caret to End-of-text (or begin-of-text if backward)
8787 ssoReplace, ssoReplaceAll, // Otherwise the function does a search only
8888 ssoPrompt, // Show the prompt before replacing
8989 ssoSearchInReplacement, // continue search-replace in replacement (with ssoReplaceAll) // replace recursive
9090 ssoRegExpr, ssoRegExprMultiLine,
9191 ssoFindContinue // Assume the current selection is the last match, and start search behind selection
9292 // (before if ssoBackward) // Default is to start at caret (Only SearchReplace / SearchReplaceEx has start/end param)
9393 );
9494```
9595
9696Returns the number of replacements done. When Searching, returns 1 if found, 0 if not found. If found the match will be selected (use BlockBegin/End).
9797
9898``` pascal
9999 if Caller.SearchReplace('FindMe', ' ', []) > 0 then begin
100100 // Selection is set to the first occurrence of FindMe (searched from position of caret)
101101 end;
102102```
103103
104104Text
105105
106106``` pascal
107107 property Lines[Index: Integer]: string; // read only
108108 property LinesCount: integer; // read only (new for Lazarus 2.2)
109109 property LineAtCaret: string; // read only
110110 procedure InsertTextAtCaret(aText: String; aCaretMode : TSynCaretAdjustMode);
111111 property TextBetweenPoints[aStartPoint, aEndPoint: TPoint]: String // Logical Points
112112 procedure SetTextBetweenPoints(aStartPoint, aEndPoint: TPoint;
113113 const AValue: String;
114114 aFlags: TSynEditTextFlags = [];
115115 aCaretMode: TSynCaretAdjustMode;
116116 aMarksMode: TSynMarksAdjustMode;
117117 aSelectionMode: TSynSelectionMode
118118 );
119119```
120120
121121Clipboard
122122
123123``` pascal
124124 procedure CopyToClipboard;
125125 procedure CutToClipboard;
126126 procedure PasteFromClipboard;
127127 property CanPaste: Boolean // read only
128128```
129129
130130Logical / Physical
131131
132132``` pascal
133133 function LogicalToPhysicalPos(const p: TPoint): TPoint;
134134 function LogicalToPhysicalCol(const Line: String; Index, LogicalPos
135135 : integer): integer;
136136 function PhysicalToLogicalPos(const p: TPoint): TPoint;
137137 function PhysicalToLogicalCol(const Line: string;
138138 Index, PhysicalPos: integer): integer;
139139 function PhysicalLineLength(Line: String; Index: integer): integer;
140140```
141141
142142### ClipBoard: TClipBoard
143143
144144``` pascal
145145 property AsText: String;
146146```
147147
148148## Available Macros / Downloads
149149
150-<table>
151-<caption>Editor macros</caption>
152-<tbody>
153-<tr>
154-<td><p><strong>Description</strong></p></td>
155-<td><p><strong>Link</strong></p></td>
156-</tr>
157-<tr>
158-<td><p><strong>Column Align Source code</strong></p>
159-<p>A macro that aligns selected code to a specific token. It looks for a specific token in each selected line, and aligns each occurrence of it.</p>
160-<p>Select the 3 lines. If the selection starts right before the ":" then the ":" will be detected. A prompt will ask you to confirm the ":". Then all ":" will be aligned. (If you use a word for alignment, please note, that it will be matched regardless of word boundaries)</p>
161-<p>You can vertically align things like := or // or (</p>
162-<table>
163-<tbody>
164-<tr>
165-<td><div class="sourceCode" id="cb1"><pre class="sourceCode pascal"><code class="sourceCode pascal"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> foo := <span class="dv">1</span>;</span>
166-<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a> something := <span class="dv">2</span>;</span>
167-<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a> x := -<span class="dv">3</span>;</span></code></pre></div></td>
168-<td><div class="sourceCode" id="cb2"><pre class="sourceCode pascal"><code class="sourceCode pascal"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> foo := <span class="dv">1</span>;</span>
169-<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> something := <span class="dv">2</span>;</span>
170-<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a> x := -<span class="dv">3</span>;</span></code></pre></div></td>
171-</tr>
172-</tbody>
173-</table></td>
174-<td><p>[[Editor Macro Column Align Source]]</p></td>
175-</tr>
176-<tr>
177-<td><p><strong>Count array elements</strong></p>
178-<p>A macro to count the boundaries in an array constant.</p>
179-<table>
180-<tbody>
181-<tr>
182-<td><div class="sourceCode" id="cb3"><pre class="sourceCode pascal"><code class="sourceCode pascal"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="kw">const</span> foo: <span class="kw">array</span> [<span class="dv">0.</span>.] <span class="kw">of</span> <span class="dt">integer</span> = (</span>
183-<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> <span class="dv">1</span>, <span class="dv">2</span>, <span class="dv">3</span>,</span>
184-<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="dv">4</span></span>
185-<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> );</span></code></pre></div></td>
186-<td><div class="sourceCode" id="cb4"><pre class="sourceCode pascal"><code class="sourceCode pascal"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="kw">const</span> foo: <span class="kw">array</span> [<span class="dv">0..3</span>] <span class="kw">of</span> <span class="dt">integer</span> = (</span>
187-<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="dv">1</span>, <span class="dv">2</span>, <span class="dv">3</span>,</span>
188-<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> <span class="dv">4</span></span>
189-<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> );</span></code></pre></div></td>
190-</tr>
191-</tbody>
192-</table></td>
193-<td><p>See <a href="http://forum.lazarus.freepascal.org/index.php/topic,27186.msg167883.html#msg167883">http://forum.lazarus.freepascal.org/index.php/topic,27186.msg167883.html#msg167883</a> for counting array elements.</p></td>
194-</tr>
195-<tr>
196-<td><p><strong>Add PasDoc for function declaration</strong></p>
197-<p>Comments a procedure/function in <a href="https://github.com/pasdoc/pasdoc/wiki">PasDoc</a> format</p>
198-<p>Example: Executing the macro with the caret in the line of function declaration will insert the comment before.</p>
199-<table>
200-<tbody>
201-<tr>
202-<td><div class="sourceCode" id="cb5"><pre class="sourceCode pascal"><code class="sourceCode pascal"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="kw">function</span> AddRadioButton(<span class="kw">const</span> aCaption: <span class="dt">string</span>; aChecked: <span class="dt">boolean</span> = <span class="kw">False</span>): TCheckBox;</span></code></pre></div></td>
203-<td><div class="sourceCode" id="cb6"><pre class="sourceCode pascal"><code class="sourceCode pascal"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="co">{ Description</span></span>
204-<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="co"> @param(aCaption description )</span></span>
205-<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a><span class="co"> @param(aChecked description )</span></span>
206-<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a><span class="co"> @returns( description )</span></span>
207-<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a><span class="co"> @raises( none )</span></span>
208-<span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a><span class="co">}</span></span>
209-<span id="cb6-7"><a href="#cb6-7" aria-hidden="true" tabindex="-1"></a><span class="kw">function</span> AddRadioButton(<span class="kw">const</span> aCaption: <span class="dt">string</span>; aChecked: <span class="dt">boolean</span> = <span class="kw">False</span>): TRadioButton;</span></code></pre></div></td>
210-</tr>
211-</tbody>
212-</table>
213-<p><a href="https://github.com/DomingoGP/LazarusMacroPasDoc"><span>https://github.com/DomingoGP/LazarusMacroPasDoc</span></a></p></td>
214-<td><p><a href="https://github.com/DomingoGP/LazarusMacroPasDoc/blob/master/MacroPasDocLazarus.txt">MacroPasDocLazarus.txt</a></p></td>
215-</tr>
216-<tr>
217-<td><p><strong>Sort selected lines</strong></p>
218-<p>There are two macros, one with the normal alphabetical order and another that orders by type</p>
219-<table>
220-<tbody>
221-<tr>
222-<td><div class="sourceCode" id="cb7"><pre class="sourceCode pascal"><code class="sourceCode pascal"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> c:<span class="dt">integer</span>;</span>
223-<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> b:<span class="dt">integer</span>;</span>
224-<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a> d:<span class="dt">boolean</span>;</span>
225-<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a> a:<span class="dt">boolean</span>;</span></code></pre></div></td>
226-<td><div class="sourceCode" id="cb8"><pre class="sourceCode pascal"><code class="sourceCode pascal"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="co">//normal sorting</span></span>
227-<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> a:<span class="dt">boolean</span>;</span>
228-<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> b:<span class="dt">integer</span>;</span>
229-<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a> c:<span class="dt">integer</span>;</span>
230-<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a> d:<span class="dt">boolean</span>;</span></code></pre></div></td>
231-<td><div class="sourceCode" id="cb9"><pre class="sourceCode pascal"><code class="sourceCode pascal"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> <span class="co">//sorting by type</span></span>
232-<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> d:<span class="dt">boolean</span>;</span>
233-<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> a:<span class="dt">boolean</span>;</span>
234-<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a> c:<span class="dt">integer</span>;</span>
235-<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a> b:<span class="dt">integer</span>; </span></code></pre></div></td>
236-</tr>
237-</tbody>
238-</table></td>
239-<td><p><a href="https://github.com/DomingoGP/LazarusMacroPasDoc/blob/master/MacroSortLinesLazarus.txt">MacroSortLinesLazarus.txt</a></p>
240-<p><a href="https://github.com/DomingoGP/LazarusMacroPasDoc/blob/master/MacroSortByTypeLazarus.txt">MacroSortByTypeLazarus.txt</a></p></td>
241-</tr>
242-<tr>
243-<td></td>
244-<td></td>
245-</tr>
246-<tr>
247-<td><p><strong>Column Align by procedure/function name the selected lines</strong></p>
248-<table>
249-<tbody>
250-<tr>
251-<td><div class="sourceCode" id="cb10"><pre class="sourceCode pascal"><code class="sourceCode pascal"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="kw">constructor</span> Create;</span>
252-<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a> <span class="kw">destructor</span> Destroy; <span class="kw">override</span>;</span>
253-<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a> <span class="kw">function</span> Load(<span class="kw">const</span> aFileName:TFileName):<span class="dt">boolean</span>;</span>
254-<span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a> <span class="kw">procedure</span> Save(<span class="kw">const</span> aFileName:TFileName); </span>
255-<span id="cb10-5"><a href="#cb10-5" aria-hidden="true" tabindex="-1"></a> <span class="kw">function</span> Size:<span class="dt">integer</span>; </span></code></pre></div></td>
256-<td><div class="sourceCode" id="cb11"><pre class="sourceCode pascal"><code class="sourceCode pascal"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> <span class="kw">constructor</span> Create;</span>
257-<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> <span class="kw">destructor</span> Destroy; <span class="kw">override</span></span>
258-<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a> <span class="kw">function</span> Load(<span class="kw">const</span> aFileName:TFileName):<span class="dt">boolean</span>;</span>
259-<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a> <span class="kw">procedure</span> Save(<span class="kw">const</span> aFileName:TFileName); </span>
260-<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a> <span class="kw">function</span> Size:<span class="dt">integer</span>;</span></code></pre></div></td>
261-</tr>
262-</tbody>
263-</table></td>
264-<td><p><a href="https://github.com/DomingoGP/LazarusMacroPasDoc/blob/master/MacroAlignFunctionProcedureNamesLazarus.txt">MacroAlignFunctionProcedureNamesLazarus.txt</a></p></td>
265-</tr>
266-<tr>
267-<td></td>
268-<td></td>
269-</tr>
270-<tr>
271-<td><p><strong>Sort selected function/procedures declarations by Name, keeps the comments before the function/procedure</strong></p>
272-<table>
273-<tbody>
274-<tr>
275-<td><div class="sourceCode" id="cb12"><pre class="sourceCode pascal"><code class="sourceCode pascal"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a> <span class="kw">destructor</span> Destroy; <span class="kw">override</span>;</span>
276-<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a> <span class="kw">constructor</span> Create;</span>
277-<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a> <span class="kw">procedure</span> Save(<span class="kw">const</span> aFileName:TFileName);</span>
278-<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a> <span class="co">{ Load the aFileName }</span></span>
279-<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a> <span class="kw">function</span> Load(<span class="kw">const</span> aFileName:TFileName):<span class="dt">boolean</span>;</span>
280-<span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a> <span class="kw">function</span> Size:<span class="dt">integer</span>; </span></code></pre></div></td>
281-<td><div class="sourceCode" id="cb13"><pre class="sourceCode pascal"><code class="sourceCode pascal"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a> <span class="kw">constructor</span> Create;</span>
282-<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a> <span class="kw">destructor</span> Destroy; <span class="kw">override</span>;</span>
283-<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a> <span class="co">{ Load the aFileName }</span></span>
284-<span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a> <span class="kw">function</span> Load(<span class="kw">const</span> aFileName:TFileName):<span class="dt">boolean</span>;</span>
285-<span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a> <span class="kw">procedure</span> Save(<span class="kw">const</span> aFileName:TFileName);</span>
286-<span id="cb13-6"><a href="#cb13-6" aria-hidden="true" tabindex="-1"></a> <span class="kw">function</span> Size:<span class="dt">integer</span>; </span></code></pre></div></td>
287-</tr>
288-</tbody>
289-</table></td>
290-<td><p><a href="https://github.com/DomingoGP/LazarusMacroPasDoc/blob/master/MacroSortFuncProcLazarus.txt">MacroSortFuncProcLazarus.txt</a></p></td>
291-</tr>
292-<tr>
293-<td></td>
294-<td></td>
295-</tr>
296-<tr>
297-<td></td>
298-<td></td>
299-</tr>
300-<tr>
301-<td><p><strong>Sort selected units in the uses clause</strong></p>
302-<table>
303-<tbody>
304-<tr>
305-<td><div class="sourceCode" id="cb14"><pre class="sourceCode pascal"><code class="sourceCode pascal"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a> <span class="kw">uses</span></span>
306-<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a> Classes, SysUtils, Forms, Controls, Graphics, Dialogs; </span></code></pre></div></td>
307-<td><div class="sourceCode" id="cb15"><pre class="sourceCode pascal"><code class="sourceCode pascal"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a> <span class="kw">uses</span></span>
308-<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a> Classes, Controls, Dialogs, Forms, Graphics, SysUtils;</span></code></pre></div></td>
309-</tr>
310-</tbody>
311-</table></td>
312-<td><p><a href="https://github.com/DomingoGP/LazarusMacroPasDoc/blob/master/MacroSortUsesLazarus.txt">MacroSortUsesLazarus.txt</a></p></td>
313-</tr>
314-<tr>
315-<td></td>
316-<td></td>
317-</tr>
318-</tbody>
319-</table>
150+Editor macros
151+
152+**Description**
153+
154+**Link**
155+
156+**Column Align Source code**
157+
158+A macro that aligns selected code to a specific token. It looks for a specific token in each selected line, and aligns each occurrence of it.
159+
160+Select the 3 lines. If the selection starts right before the ":" then the ":" will be detected. A prompt will ask you to confirm the ":". Then all ":" will be aligned. (If you use a word for alignment, please note, that it will be matched regardless of word boundaries)
161+
162+You can vertically align things like := or // or (
163+
164+``` pascal
165+ foo := 1;
166+ something := 2;
167+ x := -3;
168+```
169+
170+``` pascal
171+ foo := 1;
172+ something := 2;
173+ x := -3;
174+```
175+
176+[[Editor Macro Column Align Source]]
177+
178+**Count array elements**
179+
180+A macro to count the boundaries in an array constant.
181+
182+``` pascal
183+ const foo: array [0..] of integer = (
184+ 1, 2, 3,
185+ 4
186+ );
187+```
188+
189+``` pascal
190+ const foo: array [0..3] of integer = (
191+ 1, 2, 3,
192+ 4
193+ );
194+```
195+
196+See <http://forum.lazarus.freepascal.org/index.php/topic,27186.msg167883.html#msg167883> for counting array elements.
197+
198+**Add PasDoc for function declaration**
199+
200+Comments a procedure/function in [PasDoc](https://github.com/pasdoc/pasdoc/wiki) format
201+
202+Example: Executing the macro with the caret in the line of function declaration will insert the comment before.
203+
204+``` pascal
205+function AddRadioButton(const aCaption: string; aChecked: boolean = False): TCheckBox;
206+```
207+
208+``` pascal
209+{ Description
210+ @param(aCaption description )
211+ @param(aChecked description )
212+ @returns( description )
213+ @raises( none )
214+}
215+function AddRadioButton(const aCaption: string; aChecked: boolean = False): TRadioButton;
216+```
217+
218+[<https://github.com/DomingoGP/LazarusMacroPasDoc>](https://github.com/DomingoGP/LazarusMacroPasDoc)
219+
220+[MacroPasDocLazarus.txt](https://github.com/DomingoGP/LazarusMacroPasDoc/blob/master/MacroPasDocLazarus.txt)
221+
222+**Sort selected lines**
223+
224+There are two macros, one with the normal alphabetical order and another that orders by type
225+
226+``` pascal
227+ c:integer;
228+ b:integer;
229+ d:boolean;
230+ a:boolean;
231+```
232+
233+``` pascal
234+ //normal sorting
235+ a:boolean;
236+ b:integer;
237+ c:integer;
238+ d:boolean;
239+```
240+
241+``` pascal
242+ //sorting by type
243+ d:boolean;
244+ a:boolean;
245+ c:integer;
246+ b:integer;
247+```
248+
249+[MacroSortLinesLazarus.txt](https://github.com/DomingoGP/LazarusMacroPasDoc/blob/master/MacroSortLinesLazarus.txt)
250+
251+[MacroSortByTypeLazarus.txt](https://github.com/DomingoGP/LazarusMacroPasDoc/blob/master/MacroSortByTypeLazarus.txt)
252+
253+**Column Align by procedure/function name the selected lines**
254+
255+``` pascal
256+ constructor Create;
257+ destructor Destroy; override;
258+ function Load(const aFileName:TFileName):boolean;
259+ procedure Save(const aFileName:TFileName);
260+ function Size:integer;
261+```
262+
263+``` pascal
264+ constructor Create;
265+ destructor Destroy; override
266+ function Load(const aFileName:TFileName):boolean;
267+ procedure Save(const aFileName:TFileName);
268+ function Size:integer;
269+```
270+
271+[MacroAlignFunctionProcedureNamesLazarus.txt](https://github.com/DomingoGP/LazarusMacroPasDoc/blob/master/MacroAlignFunctionProcedureNamesLazarus.txt)
272+
273+**Sort selected function/procedures declarations by Name, keeps the comments before the function/procedure**
274+
275+``` pascal
276+ destructor Destroy; override;
277+ constructor Create;
278+ procedure Save(const aFileName:TFileName);
279+ { Load the aFileName }
280+ function Load(const aFileName:TFileName):boolean;
281+ function Size:integer;
282+```
283+
284+``` pascal
285+ constructor Create;
286+ destructor Destroy; override;
287+ { Load the aFileName }
288+ function Load(const aFileName:TFileName):boolean;
289+ procedure Save(const aFileName:TFileName);
290+ function Size:integer;
291+```
292+
293+[MacroSortFuncProcLazarus.txt](https://github.com/DomingoGP/LazarusMacroPasDoc/blob/master/MacroSortFuncProcLazarus.txt)
294+
295+**Sort selected units in the uses clause**
296+
297+``` pascal
298+ uses
299+ Classes, SysUtils, Forms, Controls, Graphics, Dialogs;
300+```
301+
302+``` pascal
303+ uses
304+ Classes, Controls, Dialogs, Forms, Graphics, SysUtils;
305+```
306+
307+[MacroSortUsesLazarus.txt](https://github.com/DomingoGP/LazarusMacroPasDoc/blob/master/MacroSortUsesLazarus.txt)
320308
321309## See also
322310
323311- [[IDE Window: Editor Macros]]
324312- [[Editor Macro Column Align Source]] - macro to align selected code to a specific token.
325313
326314---
327315*From the Free Pascal wiki, page "Editor Macros PascalScript", as it stood on 2022-01-23 after a change by DomingoGP, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history