mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-09 15:58:21 +02:00
Changes for code completion.
Shane git-svn-id: trunk@164 -
This commit is contained in:
parent
43ca80415d
commit
694b526564
@ -360,7 +360,10 @@ var
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
// update scrool bar
|
Writeln('[TSynBaseCompletionForm.Paint]');
|
||||||
|
Writeln('ItemList.Count = '+inttostr(ItemList.Count));
|
||||||
|
|
||||||
|
// update scroll bar
|
||||||
if ItemList.Count - NbLinesInWindow < 0 then
|
if ItemList.Count - NbLinesInWindow < 0 then
|
||||||
Scroll.Max := 0
|
Scroll.Max := 0
|
||||||
else
|
else
|
||||||
@ -375,27 +378,30 @@ begin
|
|||||||
Canvas.LineTo(Width - 1, Height - 1);
|
Canvas.LineTo(Width - 1, Height - 1);
|
||||||
Canvas.LineTo(0, Height - 1);
|
Canvas.LineTo(0, Height - 1);
|
||||||
Canvas.LineTo(0, 0);
|
Canvas.LineTo(0, 0);
|
||||||
|
//comments below are because canvas.draw is unfinished.
|
||||||
with bitmap do begin
|
// with bitmap do begin
|
||||||
canvas.pen.color := color;
|
canvas.pen.color := color;
|
||||||
canvas.brush.color := color;
|
canvas.brush.color := color;
|
||||||
canvas.Rectangle(0, 0, Width, Height);
|
canvas.Rectangle(0, 0, Width, Height);
|
||||||
for i := 0 to min(NbLinesInWindow - 1, ItemList.Count - 1) do begin
|
for i := 0 to min(NbLinesInWindow - 1, ItemList.Count - 1) do begin
|
||||||
if i + Scroll.Position = Position then begin
|
if i + Scroll.Position = Position then begin
|
||||||
Canvas.Brush.Color := ClSelect;
|
Canvas.Brush.Color := ClSelect;
|
||||||
Canvas.Pen.Color := ClSelect;
|
Canvas.Pen.Color := clSelect;
|
||||||
Canvas.Rectangle(0, FFontHeight * i, width, FFontHeight * (i + 1));
|
Canvas.Rectangle(0, FFontHeight * i, width, FFontHeight * (i + 1));
|
||||||
Canvas.Pen.Color := ClBlack;
|
Canvas.Pen.Color := clBlack;
|
||||||
end else
|
end else
|
||||||
Canvas.Brush.Color := Color;
|
Canvas.Brush.Color := Color;
|
||||||
|
|
||||||
if not Assigned(OnPaintItem)
|
if not Assigned(OnPaintItem)
|
||||||
or not OnPaintItem(ItemList[Scroll.Position + i], Canvas, 0, FFontHeight * i)
|
or not OnPaintItem(ItemList[Scroll.Position + i], Canvas, 0, FFontHeight * i)
|
||||||
then
|
then
|
||||||
|
Begin
|
||||||
|
Writeln('Drawing to canvas');
|
||||||
Canvas.TextOut(2, FFontHeight * i, ItemList[Scroll.Position + i]);
|
Canvas.TextOut(2, FFontHeight * i, ItemList[Scroll.Position + i]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
canvas.Draw(1, 1, bitmap);
|
//end;
|
||||||
|
//canvas.Draw(1, 1, bitmap);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSynBaseCompletionForm.ScrollChange(Sender: TObject);
|
procedure TSynBaseCompletionForm.ScrollChange(Sender: TObject);
|
||||||
@ -506,6 +512,10 @@ end;
|
|||||||
|
|
||||||
procedure TSynBaseCompletion.Execute(s: string; x, y: integer);
|
procedure TSynBaseCompletion.Execute(s: string; x, y: integer);
|
||||||
begin
|
begin
|
||||||
|
Writeln('[TSynBaseComplete.Execute] ');
|
||||||
|
Writeln('s is '+s);
|
||||||
|
Writeln('X,Y is '+inttostr(x)+','+Inttostr(y));
|
||||||
|
|
||||||
form.top := y;
|
form.top := y;
|
||||||
form.left := x;
|
form.left := x;
|
||||||
CurrentString := s;
|
CurrentString := s;
|
||||||
@ -824,15 +834,23 @@ var
|
|||||||
s: string;
|
s: string;
|
||||||
i: integer;
|
i: integer;
|
||||||
begin
|
begin
|
||||||
|
Writeln('[TSynCompletion.GetPreviousToken]');
|
||||||
|
|
||||||
if FEditor <> nil then begin
|
if FEditor <> nil then begin
|
||||||
s := FEditor.LineText;
|
s := FEditor.LineText;
|
||||||
|
Writeln('S = '+S);
|
||||||
i := FEditor.CaretX - 1;
|
i := FEditor.CaretX - 1;
|
||||||
|
Writeln('I is '+inttostr(i));
|
||||||
|
Writeln('Length(s) is= '+inttostr(length(s)));
|
||||||
if i > length(s) then
|
if i > length(s) then
|
||||||
result := ''
|
result := ''
|
||||||
else begin
|
else begin
|
||||||
while (i > 0) and (s[i] > ' ') and (pos(s[i], FEndOfTokenChr) = 0) do
|
while (i > 0) and (s[i] > ' ') {commented out by shane and (pos(s[i], FEndOfTokenChr) = 0)} do
|
||||||
|
Begin
|
||||||
dec(i);
|
dec(i);
|
||||||
|
end;
|
||||||
result := copy(s, i + 1, FEditor.CaretX - i - 1);
|
result := copy(s, i + 1, FEditor.CaretX - i - 1);
|
||||||
|
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -1025,6 +1043,8 @@ var
|
|||||||
i, j, prevspace: integer;
|
i, j, prevspace: integer;
|
||||||
StartOfBlock: tpoint;
|
StartOfBlock: tpoint;
|
||||||
begin
|
begin
|
||||||
|
Writeln('[TSynAutoComplete.Execute] ');
|
||||||
|
Writeln('Token is '+Token);
|
||||||
i := AutoCompleteList.IndexOf(token);
|
i := AutoCompleteList.IndexOf(token);
|
||||||
if i <> -1 then begin
|
if i <> -1 then begin
|
||||||
TRecordUsedToStoreEachEditorVars(fEditstuffs[fEditors.IndexOf(aEditor)]^).NoNextKey := true;
|
TRecordUsedToStoreEachEditorVars(fEditstuffs[fEditors.IndexOf(aEditor)]^).NoNextKey := true;
|
||||||
|
@ -136,6 +136,8 @@ type
|
|||||||
Procedure BookMarkToggle(Value : Integer);
|
Procedure BookMarkToggle(Value : Integer);
|
||||||
Procedure BookMarkGoto(Value : Integer);
|
Procedure BookMarkGoto(Value : Integer);
|
||||||
|
|
||||||
|
Procedure ccExecute(Sender : TObject);
|
||||||
|
|
||||||
|
|
||||||
Procedure ProcessUserCommand(Sender: TObject; var Command: TSynEditorCommand; var AChar: char; Data: pointer);
|
Procedure ProcessUserCommand(Sender: TObject; var Command: TSynEditorCommand; var AChar: char; Data: pointer);
|
||||||
|
|
||||||
@ -836,6 +838,19 @@ Begin
|
|||||||
EditorOpts.GetSynEditSettings(FEditor);
|
EditorOpts.GetSynEditSettings(FEditor);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Procedure TSourceEditor.ccExecute(Sender : TObject);
|
||||||
|
var
|
||||||
|
scompl : TSynBaseCompletion;
|
||||||
|
S : TStrings;
|
||||||
|
Begin
|
||||||
|
Writeln('[ccExecute]');
|
||||||
|
sCompl := TSynBaseCOmpletion(Sender);
|
||||||
|
S := TStringList.Create;
|
||||||
|
S.Add('constructor Create(aOwner : TComponent);');
|
||||||
|
S.Add('OnActivate');
|
||||||
|
sCompl.ItemList := S;
|
||||||
|
End;
|
||||||
|
|
||||||
|
|
||||||
Procedure TSourceEditor.CreateEditor(AOwner : TComponent; AParent: TWinControl);
|
Procedure TSourceEditor.CreateEditor(AOwner : TComponent; AParent: TWinControl);
|
||||||
Begin
|
Begin
|
||||||
@ -876,7 +891,7 @@ Begin
|
|||||||
FSynAutoComplete.AddEditor(FEditor);
|
FSynAutoComplete.AddEditor(FEditor);
|
||||||
RefreshEditorSettings;
|
RefreshEditorSettings;
|
||||||
aCompletion.Editor := FEditor;
|
aCompletion.Editor := FEditor;
|
||||||
|
aCompletion.OnExecute := @ccExecute;
|
||||||
FEditor.Lines.Assign(FSource);
|
FEditor.Lines.Assign(FSource);
|
||||||
FEditor.Setfocus
|
FEditor.Setfocus
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user