mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 15:51:12 +02:00
Editor Macros: allow non pascal macros to read sources with begin/end, if that was added by pascal script macros / improve error pos
git-svn-id: trunk@57500 -
This commit is contained in:
parent
b08adb52da
commit
7a791c20dc
@ -105,7 +105,7 @@ type
|
|||||||
FEventName: String;
|
FEventName: String;
|
||||||
FHasError: Boolean;
|
FHasError: Boolean;
|
||||||
FText, FOrigText: String;
|
FText, FOrigText: String;
|
||||||
FPos: Integer;
|
FPos, FPosCompensate: Integer;
|
||||||
FEventCommand: TSynEditorCommand;
|
FEventCommand: TSynEditorCommand;
|
||||||
FParams: Array of record
|
FParams: Array of record
|
||||||
ParamType: TSynEventParamType;
|
ParamType: TSynEventParamType;
|
||||||
@ -800,11 +800,32 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TIdeMacroEventReader.Create(const Atext: String);
|
constructor TIdeMacroEventReader.Create(const Atext: String);
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
s: String;
|
||||||
begin
|
begin
|
||||||
FText := Atext;
|
FText := Atext;
|
||||||
FOrigText := Atext;
|
FOrigText := Atext;
|
||||||
FHasError := False;
|
FHasError := False;
|
||||||
FErrorText := '';
|
FErrorText := '';
|
||||||
|
|
||||||
|
FText := TrimRight(FText);
|
||||||
|
FPosCompensate := Length(FOrigText) - Length(FText);
|
||||||
|
|
||||||
|
FText := TrimLeft(FText);
|
||||||
|
i := length(FText);
|
||||||
|
if (i > 11) and
|
||||||
|
(lowercase(copy(FText, 1, 5)) = 'begin') and
|
||||||
|
(FText[6] in [#9,#10,#13,' ']) and
|
||||||
|
(lowercase(copy(FText, i-3, 4)) = 'end.') and
|
||||||
|
(FText[i-4] in [#9,#10,#13,' '])
|
||||||
|
then begin
|
||||||
|
FText := copy(FText, 7, i-11);
|
||||||
|
FPosCompensate := FPosCompensate + 4;
|
||||||
|
s := TrimRight(FText);
|
||||||
|
FPosCompensate := FPosCompensate + Length(FText) - Length(s);
|
||||||
|
FText := Trim(FText);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TIdeMacroEventReader.EventCommand: TSynEditorCommand;
|
function TIdeMacroEventReader.EventCommand: TSynEditorCommand;
|
||||||
@ -831,11 +852,12 @@ var
|
|||||||
s: String;
|
s: String;
|
||||||
begin
|
begin
|
||||||
FEventName := '';
|
FEventName := '';
|
||||||
FText := Trim(FText);
|
FText := TrimLeft(FText);
|
||||||
|
|
||||||
Result := (FText <> '') and (not FHasError);
|
Result := (FText <> '') and (not FHasError);
|
||||||
if not Result then exit;
|
if not Result then exit;
|
||||||
Result := False;
|
Result := False;
|
||||||
FPos := Length(FOrigText) - Length(FText);
|
FPos := Length(FOrigText) - Length(FText) - FPosCompensate;
|
||||||
|
|
||||||
FHasError := True; // Assume the worst
|
FHasError := True; // Assume the worst
|
||||||
|
|
||||||
@ -849,7 +871,7 @@ begin
|
|||||||
FEventCommand := j;
|
FEventCommand := j;
|
||||||
FEventName := s;
|
FEventName := s;
|
||||||
|
|
||||||
FPos := Length(FOrigText) - Length(FText);
|
FPos := Length(FOrigText) - Length(FText) - FPosCompensate;
|
||||||
while (i <= Length(FText)) and (FText[i] in [' ', #9]) do inc (i);
|
while (i <= Length(FText)) and (FText[i] in [' ', #9]) do inc (i);
|
||||||
if (i > Length(FText)) then exit(AddError('Expected "(" or ";" bot got end of file'));
|
if (i > Length(FText)) then exit(AddError('Expected "(" or ";" bot got end of file'));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user