View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0037778 | Lazarus | Packages | public | 2020-09-19 16:33 | 2020-09-19 21:34 |
Reporter | Domingo Galmés | Assigned To | Martin Friebe | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 2.1 (SVN) | ||||
Fixed in Version | 2.2 | ||||
Summary | 0037778: [Patch] [PascalScript macros] [New feature] export the property lines.count for use in PascalScript macros. | ||||
Description | The PascalScript macros makes the property Lines of the SynEdit available but the count of lines isn't available for the macros, i thing its interesting make the count lines available so the macro's writer can test for the value and avoid accessing Lines[x] out of bounds. property Lines[Index: Integer]: string; // read only The patch suplied makes availaible the property LinesCount:integer; //read only | ||||
Steps To Reproduce | sample macro begin ShowMessage('Lines.count='+IntToStr(Caller.LinesCount)); if Caller.LinesCount>1 then ShowMessage('Second line= '+Caller.Lines[1]); end. | ||||
Tags | No tags attached. | ||||
Fixed in Revision | 63893 | ||||
LazTarget | 2.2 | ||||
Widgetset | |||||
Attached Files |
|
|
PascalScript_LinesCount.patch (3,163 bytes)
diff --git a/components/macroscript/emscriptclasses.pas b/components/macroscript/emscriptclasses.pas index 63f4d651c5..0a703c9547 100644 --- a/components/macroscript/emscriptclasses.pas +++ b/components/macroscript/emscriptclasses.pas @@ -72,6 +72,8 @@ const //PropReadId_TextBetweenPointsEx = 15x; //PropWriteId_TextBetweenPointsEx = 15x; FunctionId_SetTextBetweenPoints = 157; + PropReadId_LinesCount = 158; + PropWriteId_LinesCount = 159; FunctionId_CopyToClipboard = 160; FunctionId_CutToClipboard = 161; @@ -721,6 +723,16 @@ begin PropWriteId_Lines: begin // assert(false, 'read only'); end; + PropReadId_LinesCount: begin // + CheckMinParamCount(1, 'TSynEdit.LinesCount (r)'); + Result := GetSynEditFromStack(-2, Obj); + if not Result then + exit; + Stack.SetInt(-1, Obj.Lines.Count); + end; + PropWriteId_LinesCount: begin // + assert(false, 'read only'); + end; PropReadId_LineAtCaret: begin // CheckMinParamCount(1, 'TSynEdit.LineAtCaret (r)'); Result := GetSynEditFromStack(-2, Obj); @@ -917,6 +929,7 @@ procedure TSynEdit_SelMode_R(Self: TSynEdit; var M: TSynSelectionMode); begin // Text procedure TSynEdit_Lines_R(Self: TSynEdit; var S: string; I: Longint); begin S := Self.Lines[I]; end; +procedure TSynEdit_LinesCount_R(Self: TSynEdit; var C: integer); begin C := Self.Lines.Count; end; procedure TSynEdit_LineAtCaret_R(Self: TSynEdit; var S: string); begin S := Self.Lines[Self.CaretY-1]; end; procedure TSynEdit_TextBetweenPoints_W(Self: TSynEdit; M: String; P1, P2: TPoint); @@ -1103,6 +1116,7 @@ begin // Text RegisterProperty('Lines', 'String Integer', iptR); + RegisterProperty('LinesCount', 'Integer', iptR); RegisterProperty('LineAtCaret', 'String', iptR); // LineText RegisterMethod('procedure InsertTextAtCaret(aText: String; aCaretMode : TSynCaretAdjustMode);'); // = scamEnd RegisterProperty('TextBetweenPoints', 'String TPoint TPoint', iptRW); @@ -1160,6 +1174,7 @@ begin RegisterMethodName('SEARCHREPLACEEX', @ExecBasicHandler, Pointer(FunctionId_SearchReplaceEx), nil); RegisterPropertyNameHelper('LINES', @ExecBasicHandler, Pointer(PropReadId_Lines), nil, Pointer(PropWriteId_Lines), nil); + RegisterPropertyNameHelper('LINESCOUNT', @ExecBasicHandler, Pointer(PropReadId_LinesCount), nil, Pointer(PropWriteId_LinesCount), nil); RegisterPropertyNameHelper('LINEATCARET', @ExecBasicHandler, Pointer(PropReadId_LineAtCaret), nil, Pointer(PropWriteId_LineAtCaret), nil); RegisterMethodName('INSERTTEXTATCARET', @ExecBasicHandler, Pointer(FunctionId_InsertTextAtCaret), nil); @@ -1208,6 +1223,7 @@ begin RegisterMethod(@TEmsSynWrapper.EMS_SearchReplaceEx, 'SEARCHREPLACEEX'); RegisterPropertyHelper(@TSynEdit_Lines_R, nil, 'LINES'); + RegisterPropertyHelper(@TSynEdit_LinesCount_R, nil, 'LINESCOUNT'); RegisterPropertyHelper(@TSynEdit_LineAtCaret_R, nil, 'LINEATCARET'); RegisterMethod(@TEmsSynWrapper.EMS_InsertTextAtCaret, 'INSERTTEXTATCARET'); |
|
Thanks for the Patch. Applied in r63893 Please test and close if ok. |
|
Thanks. |
Date Modified | Username | Field | Change |
---|---|---|---|
2020-09-19 16:33 | Domingo Galmés | New Issue | |
2020-09-19 16:33 | Domingo Galmés | File Added: PascalScript_LinesCount.patch | |
2020-09-19 20:14 | Martin Friebe | Assigned To | => Martin Friebe |
2020-09-19 20:14 | Martin Friebe | Status | new => assigned |
2020-09-19 20:25 | Martin Friebe | Status | assigned => resolved |
2020-09-19 20:25 | Martin Friebe | Resolution | open => fixed |
2020-09-19 20:25 | Martin Friebe | Fixed in Version | => 2.2 |
2020-09-19 20:25 | Martin Friebe | Fixed in Revision | => 63893 |
2020-09-19 20:25 | Martin Friebe | LazTarget | => 2.2 |
2020-09-19 20:25 | Martin Friebe | Note Added: 0125645 | |
2020-09-19 21:34 | Domingo Galmés | Status | resolved => closed |
2020-09-19 21:34 | Domingo Galmés | Note Added: 0125647 |