Recent

Author Topic: Using SynAutoComplete  (Read 3468 times)

llutti

  • New Member
  • *
  • Posts: 23
Using SynAutoComplete
« on: May 23, 2016, 03:32:36 am »
Hello,

   By using SynAutoComplete to the following code:
Code: Pascal  [Select][+][-]
  1. ssa
  2. =SQL_Criar(cPesquisa);
  3. =SQL_UsarSQLSenior2(cPesquisa, 1);
  4. =SQL_UsarAbrangencia(cPesquisa, 0);
  5. =SQL_DefinirComando(cPesquisa, "| a
  6. =                              ");
  7. =SQL_AbrirCursor(cPesquisa);
  8. =nAchou = 0;
  9. =Se (SQL_EOF(cPesquisa) = cFalso)
  10. =  nAchou = 1;
  11. =SQL_Destruir(cPesquisa);

   With this situation the resulting code is:
Code: Pascal  [Select][+][-]
  1. SQL_Criar(cPesquisa);
  2. SQL_UsarSQLSenior2(cPesquisa, 1);
  3. SQL_UsarAbrangencia(cPesquisa, 0);
  4. SQL_DefinirSQL_AbrirCursor(cPesuisa);
  5. nAchou = 0;
  6. Se (SQL_EOF(cPesquisa) = cFalso)
  7.   nAchou = 1;SQL_Destruir(cPesquisa);

   To correct this situation I made the following adjustments TSynAutoComplete.Execute function:
Code: Pascal  [Select][+][-]
  1. procedure TSynAutoComplete.Execute(token: string; aEditor: TCustomSynEdit);
  2. var
  3.   Temp: string;
  4.   PosX, // llutti
  5.   i, j, prevspace: integer;
  6.   StartOfBlock: tpoint;
  7. begin
  8. //Writeln('[TSynAutoComplete.Execute] Token is "',Token,'"');
  9.   i := AutoCompleteList.IndexOf(token);
  10.  
  11.   if i <> -1 then begin
  12.     for j := 1 to length(token) do
  13.       aEditor.CommandProcessor(ecDeleteLastChar, ' ', nil);
  14.     inc(i);
  15.     PosX := aEditor.CaretX; // llutti
  16.     StartOfBlock := Point(-1, -1);
  17.     PrevSpace := 0;
  18.     while (i < AutoCompleteList.Count) and
  19.       (length(AutoCompleteList[i]) > 0) and
  20.       (AutoCompleteList[i][1] = '=') do
  21.     begin
  22.       aEditor.CaretX := PosX; // llutti
  23.       for j := 0 to PrevSpace - 1 do
  24.         aEditor.CommandProcessor(ecDeleteLastChar, ' ', nil);
  25.       Temp := AutoCompleteList[i];
  26.       PrevSpace := 0;
  27.       //while (length(temp) >= PrevSpace + 2) and (temp[PrevSpace + 2] <= ' ') do // llutti
  28.       //  inc(PrevSpace);  // lluti
  29.       for j := 2 to length(Temp) do begin
  30.         aEditor.CommandProcessor(ecChar, Temp[j], nil);
  31.         if Temp[j] = '|' then
  32.           StartOfBlock := aEditor.CaretXY
  33.       end;
  34.       inc(i);
  35.       if (i < AutoCompleteList.Count) and
  36.         (length(AutoCompleteList[i]) > 0) and
  37.         (AutoCompleteList[i][1] = '=') then
  38.         aEditor.CommandProcessor(ecLineBreak, ' ', nil);
  39.     end;
  40.     if (StartOfBlock.x <> -1) and (StartOfBlock.y <> -1) then begin
  41.       aEditor.CaretXY := StartOfBlock;
  42.       aEditor.CommandProcessor(ecDeleteLastChar, ' ', nil);
  43.     end;
  44.   end;
  45. end;

  The lines I modified are marked with "// llutti".

« Last Edit: May 24, 2016, 02:49:23 pm by llutti »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9874
  • Debugger - SynEdit - and more
    • wiki
Re: Using SynAutoComplete
« Reply #1 on: May 24, 2016, 04:52:16 pm »
Could you please report this on the bugtracker? Please include your example.

llutti

  • New Member
  • *
  • Posts: 23
Re: Using SynAutoComplete
« Reply #2 on: May 24, 2016, 07:25:38 pm »
Hi,

  I will report this situation.

 Regards,

Luciano

 

TinyPortal © 2005-2018