SynEdit: AutoComplet versus synComplete example

git-svn-id: trunk@27178 -
This commit is contained in:
martin 2010-08-24 12:58:32 +00:00
parent a740ec2386
commit a03f7f1ffc
7 changed files with 1212 additions and 0 deletions

6
.gitattributes vendored
View File

@ -2756,6 +2756,12 @@ docs/xml/rtl/README.txt svneol=native#text/plain
docs/xml/rtl/classes.xml svneol=native#text/xml
docs/xml/rtl/system.xml svneol=native#text/xml
docs/xml/rtl/sysutils.xml svneol=native#text/xml
examples/SynEdit/Completion/SynCompletionSample.ico -text
examples/SynEdit/Completion/SynCompletionSample.lpi svneol=native#text/plain
examples/SynEdit/Completion/SynCompletionSample.lpr svneol=native#text/pascal
examples/SynEdit/Completion/SynCompletionSample.res -text
examples/SynEdit/Completion/unit1.lfm svneol=native#text/plain
examples/SynEdit/Completion/unit1.pas svneol=native#text/pascal
examples/address_book/addrbook.dpr svneol=native#text/pascal
examples/address_book/addrbook.lpi svneol=native#text/plain
examples/address_book/addrbook.lpr svneol=native#text/pascal

Binary file not shown.

After

(image error) Size: 134 KiB

View File

@ -0,0 +1,233 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<MainUnit Value="0"/>
<Title Value="SynCompletionSample"/>
<UseXPManifest Value="True"/>
<Icon Value="0"/>
<ActiveWindowIndexAtStart Value="0"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="2">
<Item1>
<PackageName Value="SynEdit"/>
<MinVersion Major="1" Valid="True"/>
</Item1>
<Item2>
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="5">
<Unit0>
<Filename Value="SynCompletionSample.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="SynCompletionSample"/>
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="1" Y="20"/>
<UsageCount Value="20"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="0"/>
<WindowIndex Value="0"/>
<TopLine Value="18"/>
<CursorPos X="17" Y="71"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
<Unit2>
<Filename Value="..\..\..\components\synedit\syncompletion.pas"/>
<UnitName Value="SynCompletion"/>
<EditorIndex Value="2"/>
<WindowIndex Value="0"/>
<TopLine Value="217"/>
<CursorPos X="26" Y="250"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit2>
<Unit3>
<Filename Value="C:\FPC\SVN\trunc\rtl\i386\i386.inc"/>
<EditorIndex Value="1"/>
<WindowIndex Value="0"/>
<TopLine Value="1431"/>
<CursorPos X="1" Y="1466"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
<Filename Value="..\..\..\lcl\controls.pp"/>
<UnitName Value="Controls"/>
<EditorIndex Value="3"/>
<WindowIndex Value="0"/>
<TopLine Value="283"/>
<CursorPos X="61" Y="316"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit4>
</Units>
<JumpHistory Count="25" HistoryIndex="24">
<Position1>
<Filename Value="unit1.pas"/>
<Caret Line="9" Column="8" TopLine="1"/>
</Position1>
<Position2>
<Filename Value="unit1.pas"/>
<Caret Line="42" Column="1" TopLine="1"/>
</Position2>
<Position3>
<Filename Value="unit1.pas"/>
<Caret Line="43" Column="52" TopLine="1"/>
</Position3>
<Position4>
<Filename Value="unit1.pas"/>
<Caret Line="50" Column="18" TopLine="1"/>
</Position4>
<Position5>
<Filename Value="unit1.pas"/>
<Caret Line="56" Column="43" TopLine="1"/>
</Position5>
<Position6>
<Filename Value="unit1.pas"/>
<Caret Line="57" Column="43" TopLine="1"/>
</Position6>
<Position7>
<Filename Value="unit1.pas"/>
<Caret Line="58" Column="43" TopLine="1"/>
</Position7>
<Position8>
<Filename Value="unit1.pas"/>
<Caret Line="59" Column="43" TopLine="1"/>
</Position8>
<Position9>
<Filename Value="unit1.pas"/>
<Caret Line="58" Column="43" TopLine="1"/>
</Position9>
<Position10>
<Filename Value="unit1.pas"/>
<Caret Line="54" Column="28" TopLine="1"/>
</Position10>
<Position11>
<Filename Value="unit1.pas"/>
<Caret Line="31" Column="1" TopLine="1"/>
</Position11>
<Position12>
<Filename Value="unit1.pas"/>
<Caret Line="57" Column="1" TopLine="1"/>
</Position12>
<Position13>
<Filename Value="unit1.pas"/>
<Caret Line="59" Column="1" TopLine="1"/>
</Position13>
<Position14>
<Filename Value="unit1.pas"/>
<Caret Line="52" Column="1" TopLine="1"/>
</Position14>
<Position15>
<Filename Value="unit1.pas"/>
<Caret Line="53" Column="1" TopLine="1"/>
</Position15>
<Position16>
<Filename Value="C:\FPC\SVN\trunc\rtl\i386\i386.inc"/>
<Caret Line="1464" Column="1" TopLine="1431"/>
</Position16>
<Position17>
<Filename Value="C:\FPC\SVN\trunc\rtl\i386\i386.inc"/>
<Caret Line="1465" Column="1" TopLine="1431"/>
</Position17>
<Position18>
<Filename Value="C:\FPC\SVN\trunc\rtl\i386\i386.inc"/>
<Caret Line="1466" Column="1" TopLine="1431"/>
</Position18>
<Position19>
<Filename Value="..\..\..\components\synedit\syncompletion.pas"/>
<Caret Line="1007" Column="1" TopLine="974"/>
</Position19>
<Position20>
<Filename Value="..\..\..\components\synedit\syncompletion.pas"/>
<Caret Line="1008" Column="1" TopLine="974"/>
</Position20>
<Position21>
<Filename Value="unit1.pas"/>
<Caret Line="63" Column="27" TopLine="10"/>
</Position21>
<Position22>
<Filename Value="unit1.pas"/>
<Caret Line="32" Column="22" TopLine="1"/>
</Position22>
<Position23>
<Filename Value="unit1.pas"/>
<Caret Line="80" Column="27" TopLine="19"/>
</Position23>
<Position24>
<Filename Value="..\..\..\components\synedit\syncompletion.pas"/>
<Caret Line="250" Column="26" TopLine="217"/>
</Position24>
<Position25>
<Filename Value="unit1.pas"/>
<Caret Line="31" Column="15" TopLine="1"/>
</Position25>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="SynCompletionSample"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)\"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Debugging>
<GenerateDwarf Value="True"/>
<UseHeaptrc Value="True"/>
</Debugging>
<LinkSmart Value="True"/>
</Linking>
<Other>
<CompilerMessages>
<UseMsgFile Value="True"/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,20 @@
program SynCompletionSample;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, Unit1
{ you can add units after this };
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

Binary file not shown.

View File

@ -0,0 +1,868 @@
object Form1: TForm1
Left = 819
Height = 563
Top = 103
Width = 559
Caption = 'Form1'
ClientHeight = 563
ClientWidth = 559
OnCreate = FormCreate
LCLVersion = '0.9.29'
inline SynEdit1: TSynEdit
Left = 0
Height = 280
Top = 0
Width = 559
Align = alTop
Font.Height = -13
Font.Name = 'Courier New'
Font.Pitch = fpFixed
Font.Quality = fqNonAntialiased
ParentColor = False
ParentFont = False
TabOrder = 0
Gutter.Width = 57
Gutter.MouseActions = <
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 13
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbRight
ClickCount = ccSingle
ClickDir = cdUp
Command = 12
MoveCaret = False
Option = 0
Priority = 0
end>
RightGutter.Width = 0
RightGutter.MouseActions = <
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 13
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbRight
ClickCount = ccSingle
ClickDir = cdUp
Command = 12
MoveCaret = False
Option = 0
Priority = 0
end>
Keystrokes = <
item
Command = ecUp
ShortCut = 38
end
item
Command = ecSelUp
ShortCut = 8230
end
item
Command = ecScrollUp
ShortCut = 16422
end
item
Command = ecDown
ShortCut = 40
end
item
Command = ecSelDown
ShortCut = 8232
end
item
Command = ecScrollDown
ShortCut = 16424
end
item
Command = ecLeft
ShortCut = 37
end
item
Command = ecSelLeft
ShortCut = 8229
end
item
Command = ecWordLeft
ShortCut = 16421
end
item
Command = ecSelWordLeft
ShortCut = 24613
end
item
Command = ecRight
ShortCut = 39
end
item
Command = ecSelRight
ShortCut = 8231
end
item
Command = ecWordRight
ShortCut = 16423
end
item
Command = ecSelWordRight
ShortCut = 24615
end
item
Command = ecPageDown
ShortCut = 34
end
item
Command = ecSelPageDown
ShortCut = 8226
end
item
Command = ecPageBottom
ShortCut = 16418
end
item
Command = ecSelPageBottom
ShortCut = 24610
end
item
Command = ecPageUp
ShortCut = 33
end
item
Command = ecSelPageUp
ShortCut = 8225
end
item
Command = ecPageTop
ShortCut = 16417
end
item
Command = ecSelPageTop
ShortCut = 24609
end
item
Command = ecLineStart
ShortCut = 36
end
item
Command = ecSelLineStart
ShortCut = 8228
end
item
Command = ecEditorTop
ShortCut = 16420
end
item
Command = ecSelEditorTop
ShortCut = 24612
end
item
Command = ecLineEnd
ShortCut = 35
end
item
Command = ecSelLineEnd
ShortCut = 8227
end
item
Command = ecEditorBottom
ShortCut = 16419
end
item
Command = ecSelEditorBottom
ShortCut = 24611
end
item
Command = ecToggleMode
ShortCut = 45
end
item
Command = ecCopy
ShortCut = 16429
end
item
Command = ecPaste
ShortCut = 8237
end
item
Command = ecDeleteChar
ShortCut = 46
end
item
Command = ecCut
ShortCut = 8238
end
item
Command = ecDeleteLastChar
ShortCut = 8
end
item
Command = ecDeleteLastChar
ShortCut = 8200
end
item
Command = ecDeleteLastWord
ShortCut = 16392
end
item
Command = ecUndo
ShortCut = 32776
end
item
Command = ecRedo
ShortCut = 40968
end
item
Command = ecLineBreak
ShortCut = 13
end
item
Command = ecSelectAll
ShortCut = 16449
end
item
Command = ecCopy
ShortCut = 16451
end
item
Command = ecBlockIndent
ShortCut = 24649
end
item
Command = ecLineBreak
ShortCut = 16461
end
item
Command = ecInsertLine
ShortCut = 16462
end
item
Command = ecDeleteWord
ShortCut = 16468
end
item
Command = ecBlockUnindent
ShortCut = 24661
end
item
Command = ecPaste
ShortCut = 16470
end
item
Command = ecCut
ShortCut = 16472
end
item
Command = ecDeleteLine
ShortCut = 16473
end
item
Command = ecDeleteEOL
ShortCut = 24665
end
item
Command = ecUndo
ShortCut = 16474
end
item
Command = ecRedo
ShortCut = 24666
end
item
Command = ecGotoMarker0
ShortCut = 16432
end
item
Command = ecGotoMarker1
ShortCut = 16433
end
item
Command = ecGotoMarker2
ShortCut = 16434
end
item
Command = ecGotoMarker3
ShortCut = 16435
end
item
Command = ecGotoMarker4
ShortCut = 16436
end
item
Command = ecGotoMarker5
ShortCut = 16437
end
item
Command = ecGotoMarker6
ShortCut = 16438
end
item
Command = ecGotoMarker7
ShortCut = 16439
end
item
Command = ecGotoMarker8
ShortCut = 16440
end
item
Command = ecGotoMarker9
ShortCut = 16441
end
item
Command = ecSetMarker0
ShortCut = 24624
end
item
Command = ecSetMarker1
ShortCut = 24625
end
item
Command = ecSetMarker2
ShortCut = 24626
end
item
Command = ecSetMarker3
ShortCut = 24627
end
item
Command = ecSetMarker4
ShortCut = 24628
end
item
Command = ecSetMarker5
ShortCut = 24629
end
item
Command = ecSetMarker6
ShortCut = 24630
end
item
Command = ecSetMarker7
ShortCut = 24631
end
item
Command = ecSetMarker8
ShortCut = 24632
end
item
Command = ecSetMarker9
ShortCut = 24633
end
item
Command = EcFoldLevel1
ShortCut = 41009
end
item
Command = EcFoldLevel2
ShortCut = 41010
end
item
Command = EcFoldLevel1
ShortCut = 41011
end
item
Command = EcFoldLevel1
ShortCut = 41012
end
item
Command = EcFoldLevel1
ShortCut = 41013
end
item
Command = EcFoldLevel6
ShortCut = 41014
end
item
Command = EcFoldLevel7
ShortCut = 41015
end
item
Command = EcFoldLevel8
ShortCut = 41016
end
item
Command = EcFoldLevel9
ShortCut = 41017
end
item
Command = EcFoldLevel0
ShortCut = 41008
end
item
Command = EcFoldCurrent
ShortCut = 41005
end
item
Command = EcUnFoldCurrent
ShortCut = 41003
end
item
Command = EcToggleMarkupWord
ShortCut = 32845
end
item
Command = ecNormalSelect
ShortCut = 24654
end
item
Command = ecColumnSelect
ShortCut = 24643
end
item
Command = ecLineSelect
ShortCut = 24652
end
item
Command = ecTab
ShortCut = 9
end
item
Command = ecShiftTab
ShortCut = 8201
end
item
Command = ecMatchBracket
ShortCut = 24642
end
item
Command = ecColSelUp
ShortCut = 40998
end
item
Command = ecColSelDown
ShortCut = 41000
end
item
Command = ecColSelLeft
ShortCut = 40997
end
item
Command = ecColSelRight
ShortCut = 40999
end
item
Command = ecColSelPageDown
ShortCut = 40994
end
item
Command = ecColSelPageBottom
ShortCut = 57378
end
item
Command = ecColSelPageUp
ShortCut = 40993
end
item
Command = ecColSelPageTop
ShortCut = 57377
end
item
Command = ecColSelLineStart
ShortCut = 40996
end
item
Command = ecColSelLineEnd
ShortCut = 40995
end
item
Command = ecColSelEditorTop
ShortCut = 57380
end
item
Command = ecColSelEditorBottom
ShortCut = 57379
end>
MouseActions = <
item
Shift = []
ShiftMask = [ssShift, ssAlt]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown
Command = 1
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = [ssShift]
ShiftMask = [ssShift, ssAlt]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown
Command = 1
MoveCaret = True
Option = 1
Priority = 0
end
item
Shift = [ssAlt]
ShiftMask = [ssShift, ssAlt]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown
Command = 3
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = [ssShift, ssAlt]
ShiftMask = [ssShift, ssAlt]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown
Command = 3
MoveCaret = True
Option = 1
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbRight
ClickCount = ccSingle
ClickDir = cdUp
Command = 12
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccDouble
ClickDir = cdDown
Command = 6
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccTriple
ClickDir = cdDown
Command = 7
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccQuad
ClickDir = cdDown
Command = 8
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbMiddle
ClickCount = ccSingle
ClickDir = cdDown
Command = 10
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = [ssCtrl]
ShiftMask = [ssShift, ssAlt, ssCtrl]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdUp
Command = 11
MoveCaret = False
Option = 0
Priority = 0
end>
MouseSelActions = <
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown
Command = 9
MoveCaret = False
Option = 0
Priority = 0
end>
Lines.Strings = (
'Press shift-space at the end of the next line(s):'
''
'pc'
'po'
'me'
''
'Press ctrl-space at the end of the next line(s):'
''
'p'
'pe'
'po'
'co'
''
)
Options = [eoAutoIndent, eoGroupUndo, eoSmartTabs, eoTabsToSpaces, eoTrimTrailingSpaces, eoBracketHighlight]
BracketHighlightStyle = sbhsBoth
inline SynLeftGutterPartList1: TSynGutterPartList
object SynGutterMarks1: TSynGutterMarks
Width = 24
end
object SynGutterLineNumber1: TSynGutterLineNumber
Width = 17
MouseActions = <>
MarkupInfo.Background = clBtnFace
MarkupInfo.Foreground = clNone
DigitCount = 2
ShowOnlyLineNumbersMultiplesOf = 1
ZeroStart = False
LeadingZeros = False
end
object SynGutterChanges1: TSynGutterChanges
Width = 4
ModifiedColor = 59900
SavedColor = clGreen
end
object SynGutterSeparator1: TSynGutterSeparator
Width = 2
end
object SynGutterCodeFolding1: TSynGutterCodeFolding
MouseActions = <
item
Shift = []
ShiftMask = []
Button = mbRight
ClickCount = ccSingle
ClickDir = cdUp
Command = 16
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = [ssShift]
Button = mbMiddle
ClickCount = ccAny
ClickDir = cdDown
Command = 14
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = [ssShift]
ShiftMask = [ssShift]
Button = mbMiddle
ClickCount = ccAny
ClickDir = cdDown
Command = 14
MoveCaret = False
Option = 1
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 0
MoveCaret = False
Option = 0
Priority = 0
end>
MarkupInfo.Background = clNone
MarkupInfo.Foreground = clGray
MouseActionsExpanded = <
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 14
MoveCaret = False
Option = 0
Priority = 0
end>
MouseActionsCollapsed = <
item
Shift = [ssCtrl]
ShiftMask = [ssCtrl]
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 15
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = [ssCtrl]
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 15
MoveCaret = False
Option = 1
Priority = 0
end>
end
end
inline SynRightGutterPartList1: TSynRightGutterPartList
end
end
object Splitter1: TSplitter
Cursor = crVSplit
Left = 0
Height = 5
Top = 280
Width = 559
Align = alTop
ResizeAnchor = akTop
end
object Panel2: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Splitter1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 278
Top = 285
Width = 559
Anchors = [akTop, akLeft, akRight, akBottom]
Caption = 'Panel2'
ClientHeight = 278
ClientWidth = 559
TabOrder = 2
object Panel1: TPanel
Left = 1
Height = 276
Top = 1
Width = 282
Align = alLeft
Caption = 'Panel1'
ClientHeight = 276
ClientWidth = 282
TabOrder = 0
object Label1: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 1
Height = 16
Top = 1
Width = 280
Anchors = [akTop, akLeft, akRight]
Caption = 'Press shift-space for autocomplete'
ParentColor = False
WordWrap = True
end
object Memo1: TMemo
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Panel1
AnchorSideBottom.Side = asrBottom
Left = 1
Height = 242
Top = 33
Width = 280
Anchors = [akTop, akLeft, akRight, akBottom]
Lines.Strings = (
'pc'
'=Personal Computer'
'=Police Constable'
'po'
'=Post Office'
'=Private Office'
'me'
'=The Author'
)
OnChange = Memo1Change
TabOrder = 0
end
object Label2: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 1
Height = 16
Top = 17
Width = 280
Anchors = [akTop, akLeft, akRight]
Caption = 'AutocompleteList:'
ParentColor = False
end
end
object Splitter2: TSplitter
Left = 283
Height = 276
Top = 1
Width = 5
end
object Memo2: TMemo
Left = 288
Height = 276
Top = 1
Width = 270
Align = alClient
Lines.Strings = (
'For TsynComplete press ctrl-space.'
''
'values are'
'Personal Computer'
'Personal'
'Computer'
'Police Constable'
'Police'
'Constable'
)
ReadOnly = True
TabOrder = 2
end
end
object SynAutoComplete1: TSynAutoComplete
EndOfTokenChr = '()[].'
Editor = SynEdit1
ShortCut = 8224
left = 211
top = 83
end
end

View File

@ -0,0 +1,85 @@
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, SynEdit,
SynCompletion;
type
{ TForm1 }
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Memo1: TMemo;
Memo2: TMemo;
Panel1: TPanel;
Panel2: TPanel;
Splitter1: TSplitter;
Splitter2: TSplitter;
SynAutoComplete1: TSynAutoComplete;
SynEdit1: TSynEdit;
procedure FormCreate(Sender: TObject);
procedure Memo1Change(Sender: TObject);
private
{ private declarations }
SynCompletion: TSynCompletion;
procedure DoExecute(Sender: TObject);
procedure DoSearchPosition(var APosition: integer);
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Memo1Change(Sender: TObject);
begin
SynAutoComplete1.AutoCompleteList := Memo1.Lines;
end;
procedure TForm1.DoExecute(Sender: TObject);
procedure Add(s: String);
begin
if pos(lowercase(SynCompletion.CurrentString), lowercase(s)) = 1 then
SynCompletion.ItemList.Add(s);
end;
begin
SynCompletion.ItemList.Clear;
Add('Personal Computer');
Add('Personal');
Add('Computer');
Add('Police Constable');
Add('Police');
Add('Constable');
end;
procedure TForm1.DoSearchPosition(var APosition: integer);
begin
DoExecute(nil);
APosition := 0;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Memo1Change(nil);
SynCompletion := TSynCompletion.Create(Form1);
SynCompletion.Editor := SynEdit1;
SynCompletion.CaseSensitive := False;
SynCompletion.OnExecute := @DoExecute;
SynCompletion.OnSearchPosition := @DoSearchPosition;
end;
end.