procedure TSynAutoComplete.Execute(token: string; aEditor: TCustomSynEdit);
var
Temp: string;
PosX, // llutti
i, j, prevspace: integer;
StartOfBlock: tpoint;
begin
//Writeln('[TSynAutoComplete.Execute] Token is "',Token,'"');
i := AutoCompleteList.IndexOf(token);
if i <> -1 then begin
for j := 1 to length(token) do
aEditor.CommandProcessor(ecDeleteLastChar, ' ', nil);
inc(i);
PosX := aEditor.CaretX; // llutti
StartOfBlock := Point(-1, -1);
PrevSpace := 0;
while (i < AutoCompleteList.Count) and
(length(AutoCompleteList[i]) > 0) and
(AutoCompleteList[i][1] = '=') do
begin
aEditor.CaretX := PosX; // llutti
for j := 0 to PrevSpace - 1 do
aEditor.CommandProcessor(ecDeleteLastChar, ' ', nil);
Temp := AutoCompleteList[i];
PrevSpace := 0;
//while (length(temp) >= PrevSpace + 2) and (temp[PrevSpace + 2] <= ' ') do // llutti
// inc(PrevSpace); // lluti
for j := 2 to length(Temp) do begin
aEditor.CommandProcessor(ecChar, Temp[j], nil);
if Temp[j] = '|' then
StartOfBlock := aEditor.CaretXY
end;
inc(i);
if (i < AutoCompleteList.Count) and
(length(AutoCompleteList[i]) > 0) and
(AutoCompleteList[i][1] = '=') then
aEditor.CommandProcessor(ecLineBreak, ' ', nil);
end;
if (StartOfBlock.x <> -1) and (StartOfBlock.y <> -1) then begin
aEditor.CaretXY := StartOfBlock;
aEditor.CommandProcessor(ecDeleteLastChar, ' ', nil);
end;
end;
end;