mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-03 20:59:30 +01:00
examples: added example for synpositionhighlighter
git-svn-id: trunk@15889 -
This commit is contained in:
parent
9631a38f58
commit
a93efcf0f1
5
.gitattributes
vendored
5
.gitattributes
vendored
@ -1915,6 +1915,11 @@ examples/std_actions/unit1.pas svneol=native#text/pascal
|
||||
examples/synchronize.pp svneol=native#text/pascal
|
||||
examples/synedit1.lpi svneol=native#text/plain
|
||||
examples/synedit1.pas svneol=native#text/pascal
|
||||
examples/synpositionhighlighter/synpositionhighlighterexample1.lpi svneol=native#text/plain
|
||||
examples/synpositionhighlighter/synpositionhighlighterexample1.lpr svneol=native#text/plain
|
||||
examples/synpositionhighlighter/unit1.lfm svneol=native#text/plain
|
||||
examples/synpositionhighlighter/unit1.lrs svneol=native#text/plain
|
||||
examples/synpositionhighlighter/unit1.pas svneol=native#text/plain
|
||||
examples/taborder.lpi svneol=native#text/plain
|
||||
examples/taborder.pas svneol=native#text/pascal
|
||||
examples/testall.lpi svneol=native#text/plain
|
||||
|
||||
@ -21,7 +21,8 @@ unit SynHighlighterPosition;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, SynEditStrConst, SynEditTypes, SynEditHighlighter;
|
||||
Classes, SysUtils, Graphics, SynEditStrConst, SynEditTypes,
|
||||
SynEditHighlighter;
|
||||
|
||||
const
|
||||
tkNone = 0;
|
||||
@ -45,6 +46,8 @@ type
|
||||
end;
|
||||
PPositionTokens = ^TPositionTokens;
|
||||
|
||||
{ TSynPositionHighlighter }
|
||||
|
||||
TSynPositionHighlighter = class(TSynCustomHighlighter)
|
||||
private
|
||||
fCopiedAttributes: TList;
|
||||
@ -88,12 +91,20 @@ type
|
||||
procedure EnumUserSettings(settings: TStrings); override;
|
||||
property IdentChars;
|
||||
public
|
||||
procedure AddToken(Line, Col: integer; TokenKind: TtkTokenKind);
|
||||
procedure ClearTokens(Line: integer);
|
||||
procedure AddToken(Line, // 0 based
|
||||
Col: integer; // 1 based
|
||||
TokenKind: TtkTokenKind);
|
||||
procedure ClearTokens(Line: integer // 0 based
|
||||
);
|
||||
procedure ClearAllCopiedAttributes;
|
||||
procedure ClearAllTokens;
|
||||
procedure InsertTokens(Lines: TStringList;
|
||||
Highlighter: TSynCustomHighlighter; Line, Col: integer);
|
||||
Highlighter: TSynCustomHighlighter;
|
||||
Line, //0 based
|
||||
Col: integer // 1 based
|
||||
);
|
||||
function CreateTokenID(const aName: string; Foreground, BackGround: TColor;
|
||||
Style: TFontStyles): TtkTokenKind;
|
||||
function GetCopiedTokenID(Attr: TSynHighlighterAttributes): TtkTokenKind;
|
||||
function GetCopiedAttribute(TokenID: TtkTokenKind): TSynHighlighterAttributes;
|
||||
property Tokens[TheLineNumber: integer]: PPositionTokens read GetTokens;
|
||||
@ -382,6 +393,20 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSynPositionHighlighter.CreateTokenID(const aName: string;
|
||||
Foreground, BackGround: TColor;
|
||||
Style: TFontStyles): TtkTokenKind;
|
||||
var
|
||||
Attr: TSynHighlighterAttributes;
|
||||
begin
|
||||
Attr:=TSynHighlighterAttributes.Create(aName);
|
||||
Attr.Foreground:=Foreground;
|
||||
Attr.Background:=BackGround;
|
||||
Attr.Style:=Style;
|
||||
Result:=GetCopiedTokenID(Attr);
|
||||
Attr.Free;
|
||||
end;
|
||||
|
||||
function TSynPositionHighlighter.GetCopiedTokenID(
|
||||
Attr: TSynHighlighterAttributes): TtkTokenKind;
|
||||
var
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<PathDelim Value="/"/>
|
||||
<Version Value="6"/>
|
||||
<General>
|
||||
<SessionStorage Value="InIDEConfig"/>
|
||||
<MainUnit Value="0"/>
|
||||
<TargetFileExt Value=""/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<ProjectVersion Value=""/>
|
||||
</VersionInfo>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IgnoreBinaries Value="False"/>
|
||||
<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"/>
|
||||
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="SynEdit"/>
|
||||
<MinVersion Major="1" Valid="True"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="synpositionhighlighterexample1.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="SynPositionHighlighterExample1"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<ResourceFilename Value="unit1.lrs"/>
|
||||
<UnitName Value="Unit1"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="5"/>
|
||||
<CodeGeneration>
|
||||
<Generate Value="Faster"/>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</CONFIG>
|
||||
@ -0,0 +1,18 @@
|
||||
program SynPositionHighlighterExample1;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms
|
||||
{ you can add units after this }, Unit1;
|
||||
|
||||
begin
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
||||
371
examples/synpositionhighlighter/unit1.lfm
Normal file
371
examples/synpositionhighlighter/unit1.lfm
Normal file
@ -0,0 +1,371 @@
|
||||
object Form1: TForm1
|
||||
Left = 290
|
||||
Height = 300
|
||||
Top = 189
|
||||
Width = 400
|
||||
Caption = 'Form1'
|
||||
ClientHeight = 275
|
||||
ClientWidth = 400
|
||||
Menu = MainMenu1
|
||||
OnCreate = FormCreate
|
||||
LCLVersion = '0.9.25'
|
||||
object SynEdit1: TSynEdit
|
||||
Height = 275
|
||||
Width = 400
|
||||
Align = alClient
|
||||
Font.Height = 12
|
||||
Font.Name = 'courier'
|
||||
Font.Pitch = fpFixed
|
||||
ParentColor = False
|
||||
TabOrder = 0
|
||||
BookMarkOptions.OnChange = nil
|
||||
Gutter.CodeFoldingWidth = 14
|
||||
Keystrokes = <
|
||||
item
|
||||
Command = 3
|
||||
ShortCut = 38
|
||||
end
|
||||
item
|
||||
Command = 103
|
||||
ShortCut = 8230
|
||||
end
|
||||
item
|
||||
Command = 211
|
||||
ShortCut = 16422
|
||||
end
|
||||
item
|
||||
Command = 4
|
||||
ShortCut = 40
|
||||
end
|
||||
item
|
||||
Command = 104
|
||||
ShortCut = 8232
|
||||
end
|
||||
item
|
||||
Command = 212
|
||||
ShortCut = 16424
|
||||
end
|
||||
item
|
||||
Command = 1
|
||||
ShortCut = 37
|
||||
end
|
||||
item
|
||||
Command = 101
|
||||
ShortCut = 8229
|
||||
end
|
||||
item
|
||||
Command = 5
|
||||
ShortCut = 16421
|
||||
end
|
||||
item
|
||||
Command = 105
|
||||
ShortCut = 24613
|
||||
end
|
||||
item
|
||||
Command = 2
|
||||
ShortCut = 39
|
||||
end
|
||||
item
|
||||
Command = 102
|
||||
ShortCut = 8231
|
||||
end
|
||||
item
|
||||
Command = 6
|
||||
ShortCut = 16423
|
||||
end
|
||||
item
|
||||
Command = 106
|
||||
ShortCut = 24615
|
||||
end
|
||||
item
|
||||
Command = 10
|
||||
ShortCut = 34
|
||||
end
|
||||
item
|
||||
Command = 110
|
||||
ShortCut = 8226
|
||||
end
|
||||
item
|
||||
Command = 14
|
||||
ShortCut = 16418
|
||||
end
|
||||
item
|
||||
Command = 114
|
||||
ShortCut = 24610
|
||||
end
|
||||
item
|
||||
Command = 9
|
||||
ShortCut = 33
|
||||
end
|
||||
item
|
||||
Command = 109
|
||||
ShortCut = 8225
|
||||
end
|
||||
item
|
||||
Command = 13
|
||||
ShortCut = 16417
|
||||
end
|
||||
item
|
||||
Command = 113
|
||||
ShortCut = 24609
|
||||
end
|
||||
item
|
||||
Command = 7
|
||||
ShortCut = 36
|
||||
end
|
||||
item
|
||||
Command = 107
|
||||
ShortCut = 8228
|
||||
end
|
||||
item
|
||||
Command = 15
|
||||
ShortCut = 16420
|
||||
end
|
||||
item
|
||||
Command = 115
|
||||
ShortCut = 24612
|
||||
end
|
||||
item
|
||||
Command = 8
|
||||
ShortCut = 35
|
||||
end
|
||||
item
|
||||
Command = 108
|
||||
ShortCut = 8227
|
||||
end
|
||||
item
|
||||
Command = 16
|
||||
ShortCut = 16419
|
||||
end
|
||||
item
|
||||
Command = 116
|
||||
ShortCut = 24611
|
||||
end
|
||||
item
|
||||
Command = 223
|
||||
ShortCut = 45
|
||||
end
|
||||
item
|
||||
Command = 201
|
||||
ShortCut = 16429
|
||||
end
|
||||
item
|
||||
Command = 604
|
||||
ShortCut = 8237
|
||||
end
|
||||
item
|
||||
Command = 502
|
||||
ShortCut = 46
|
||||
end
|
||||
item
|
||||
Command = 603
|
||||
ShortCut = 8238
|
||||
end
|
||||
item
|
||||
Command = 501
|
||||
ShortCut = 8
|
||||
end
|
||||
item
|
||||
Command = 501
|
||||
ShortCut = 8200
|
||||
end
|
||||
item
|
||||
Command = 504
|
||||
ShortCut = 16392
|
||||
end
|
||||
item
|
||||
Command = 601
|
||||
ShortCut = 32776
|
||||
end
|
||||
item
|
||||
Command = 602
|
||||
ShortCut = 40968
|
||||
end
|
||||
item
|
||||
Command = 509
|
||||
ShortCut = 13
|
||||
end
|
||||
item
|
||||
Command = 199
|
||||
ShortCut = 16449
|
||||
end
|
||||
item
|
||||
Command = 201
|
||||
ShortCut = 16451
|
||||
end
|
||||
item
|
||||
Command = 610
|
||||
ShortCut = 24649
|
||||
end
|
||||
item
|
||||
Command = 509
|
||||
ShortCut = 16461
|
||||
end
|
||||
item
|
||||
Command = 510
|
||||
ShortCut = 16462
|
||||
end
|
||||
item
|
||||
Command = 503
|
||||
ShortCut = 16468
|
||||
end
|
||||
item
|
||||
Command = 611
|
||||
ShortCut = 24661
|
||||
end
|
||||
item
|
||||
Command = 604
|
||||
ShortCut = 16470
|
||||
end
|
||||
item
|
||||
Command = 603
|
||||
ShortCut = 16472
|
||||
end
|
||||
item
|
||||
Command = 507
|
||||
ShortCut = 16473
|
||||
end
|
||||
item
|
||||
Command = 506
|
||||
ShortCut = 24665
|
||||
end
|
||||
item
|
||||
Command = 601
|
||||
ShortCut = 16474
|
||||
end
|
||||
item
|
||||
Command = 602
|
||||
ShortCut = 24666
|
||||
end
|
||||
item
|
||||
Command = 301
|
||||
ShortCut = 16432
|
||||
end
|
||||
item
|
||||
Command = 302
|
||||
ShortCut = 16433
|
||||
end
|
||||
item
|
||||
Command = 303
|
||||
ShortCut = 16434
|
||||
end
|
||||
item
|
||||
Command = 304
|
||||
ShortCut = 16435
|
||||
end
|
||||
item
|
||||
Command = 305
|
||||
ShortCut = 16436
|
||||
end
|
||||
item
|
||||
Command = 306
|
||||
ShortCut = 16437
|
||||
end
|
||||
item
|
||||
Command = 307
|
||||
ShortCut = 16438
|
||||
end
|
||||
item
|
||||
Command = 308
|
||||
ShortCut = 16439
|
||||
end
|
||||
item
|
||||
Command = 309
|
||||
ShortCut = 16440
|
||||
end
|
||||
item
|
||||
Command = 310
|
||||
ShortCut = 16441
|
||||
end
|
||||
item
|
||||
Command = 351
|
||||
ShortCut = 24624
|
||||
end
|
||||
item
|
||||
Command = 352
|
||||
ShortCut = 24625
|
||||
end
|
||||
item
|
||||
Command = 353
|
||||
ShortCut = 24626
|
||||
end
|
||||
item
|
||||
Command = 354
|
||||
ShortCut = 24627
|
||||
end
|
||||
item
|
||||
Command = 355
|
||||
ShortCut = 24628
|
||||
end
|
||||
item
|
||||
Command = 356
|
||||
ShortCut = 24629
|
||||
end
|
||||
item
|
||||
Command = 357
|
||||
ShortCut = 24630
|
||||
end
|
||||
item
|
||||
Command = 358
|
||||
ShortCut = 24631
|
||||
end
|
||||
item
|
||||
Command = 359
|
||||
ShortCut = 24632
|
||||
end
|
||||
item
|
||||
Command = 360
|
||||
ShortCut = 24633
|
||||
end
|
||||
item
|
||||
Command = 231
|
||||
ShortCut = 24654
|
||||
end
|
||||
item
|
||||
Command = 232
|
||||
ShortCut = 24643
|
||||
end
|
||||
item
|
||||
Command = 233
|
||||
ShortCut = 24652
|
||||
end
|
||||
item
|
||||
Command = 612
|
||||
ShortCut = 9
|
||||
end
|
||||
item
|
||||
Command = 613
|
||||
ShortCut = 8201
|
||||
end
|
||||
item
|
||||
Command = 250
|
||||
ShortCut = 24642
|
||||
end>
|
||||
Lines.Strings = (
|
||||
'SynEdit1'
|
||||
)
|
||||
SelectedColor.OnChange = nil
|
||||
end
|
||||
object MainMenu1: TMainMenu
|
||||
left = 83
|
||||
top = 61
|
||||
object FileMenuItem: TMenuItem
|
||||
Caption = 'File'
|
||||
object OpenMenuItem: TMenuItem
|
||||
Caption = 'Open'
|
||||
OnClick = OpenMenuItemClick
|
||||
end
|
||||
object MenuItem2: TMenuItem
|
||||
Caption = '-'
|
||||
end
|
||||
object ExitMenuItem: TMenuItem
|
||||
Caption = 'Exit'
|
||||
end
|
||||
end
|
||||
end
|
||||
object OpenDialog1: TOpenDialog
|
||||
Options = [ofFileMustExist, ofEnableSizing, ofViewDetail]
|
||||
left = 135
|
||||
top = 60
|
||||
end
|
||||
end
|
||||
60
examples/synpositionhighlighter/unit1.lrs
Normal file
60
examples/synpositionhighlighter/unit1.lrs
Normal file
@ -0,0 +1,60 @@
|
||||
{ This is an automatically generated lazarus resource file }
|
||||
|
||||
LazarusResources.Add('TForm1','FORMDATA',[
|
||||
'TPF0'#6'TForm1'#5'Form1'#4'Left'#3'"'#1#6'Height'#3','#1#3'Top'#3#189#0#5'Wi'
|
||||
+'dth'#3#144#1#7'Caption'#6#5'Form1'#12'ClientHeight'#3#19#1#11'ClientWidth'#3
|
||||
+#144#1#4'Menu'#7#9'MainMenu1'#8'OnCreate'#7#10'FormCreate'#10'LCLVersion'#6#6
|
||||
+'0.9.25'#0#8'TSynEdit'#8'SynEdit1'#6'Height'#3#19#1#5'Width'#3#144#1#5'Align'
|
||||
+#7#8'alClient'#11'Font.Height'#2#12#9'Font.Name'#6#7'courier'#10'Font.Pitch'
|
||||
+#7#7'fpFixed'#11'ParentColor'#8#8'TabOrder'#2#0#24'BookMarkOptions.OnChange'
|
||||
+#13#23'Gutter.CodeFoldingWidth'#2#14#10'Keystrokes'#14#1#7'Command'#2#3#8'Sh'
|
||||
+'ortCut'#2'&'#0#1#7'Command'#2'g'#8'ShortCut'#3'& '#0#1#7'Command'#3#211#0#8
|
||||
+'ShortCut'#3'&@'#0#1#7'Command'#2#4#8'ShortCut'#2'('#0#1#7'Command'#2'h'#8'S'
|
||||
+'hortCut'#3'( '#0#1#7'Command'#3#212#0#8'ShortCut'#3'(@'#0#1#7'Command'#2#1#8
|
||||
+'ShortCut'#2'%'#0#1#7'Command'#2'e'#8'ShortCut'#3'% '#0#1#7'Command'#2#5#8'S'
|
||||
+'hortCut'#3'%@'#0#1#7'Command'#2'i'#8'ShortCut'#3'%`'#0#1#7'Command'#2#2#8'S'
|
||||
+'hortCut'#2''''#0#1#7'Command'#2'f'#8'ShortCut'#3''' '#0#1#7'Command'#2#6#8
|
||||
+'ShortCut'#3'''@'#0#1#7'Command'#2'j'#8'ShortCut'#3'''`'#0#1#7'Command'#2#10
|
||||
+#8'ShortCut'#2'"'#0#1#7'Command'#2'n'#8'ShortCut'#3'" '#0#1#7'Command'#2#14#8
|
||||
+'ShortCut'#3'"@'#0#1#7'Command'#2'r'#8'ShortCut'#3'"`'#0#1#7'Command'#2#9#8
|
||||
+'ShortCut'#2'!'#0#1#7'Command'#2'm'#8'ShortCut'#3'! '#0#1#7'Command'#2#13#8
|
||||
+'ShortCut'#3'!@'#0#1#7'Command'#2'q'#8'ShortCut'#3'!`'#0#1#7'Command'#2#7#8
|
||||
+'ShortCut'#2'$'#0#1#7'Command'#2'k'#8'ShortCut'#3'$ '#0#1#7'Command'#2#15#8
|
||||
+'ShortCut'#3'$@'#0#1#7'Command'#2's'#8'ShortCut'#3'$`'#0#1#7'Command'#2#8#8
|
||||
+'ShortCut'#2'#'#0#1#7'Command'#2'l'#8'ShortCut'#3'# '#0#1#7'Command'#2#16#8
|
||||
+'ShortCut'#3'#@'#0#1#7'Command'#2't'#8'ShortCut'#3'#`'#0#1#7'Command'#3#223#0
|
||||
+#8'ShortCut'#2'-'#0#1#7'Command'#3#201#0#8'ShortCut'#3'-@'#0#1#7'Command'#3
|
||||
+'\'#2#8'ShortCut'#3'- '#0#1#7'Command'#3#246#1#8'ShortCut'#2'.'#0#1#7'Comman'
|
||||
+'d'#3'['#2#8'ShortCut'#3'. '#0#1#7'Command'#3#245#1#8'ShortCut'#2#8#0#1#7'Co'
|
||||
+'mmand'#3#245#1#8'ShortCut'#3#8' '#0#1#7'Command'#3#248#1#8'ShortCut'#3#8'@'
|
||||
+#0#1#7'Command'#3'Y'#2#8'ShortCut'#4#8#128#0#0#0#1#7'Command'#3'Z'#2#8'Short'
|
||||
+'Cut'#4#8#160#0#0#0#1#7'Command'#3#253#1#8'ShortCut'#2#13#0#1#7'Command'#3
|
||||
+#199#0#8'ShortCut'#3'A@'#0#1#7'Command'#3#201#0#8'ShortCut'#3'C@'#0#1#7'Comm'
|
||||
+'and'#3'b'#2#8'ShortCut'#3'I`'#0#1#7'Command'#3#253#1#8'ShortCut'#3'M@'#0#1#7
|
||||
+'Command'#3#254#1#8'ShortCut'#3'N@'#0#1#7'Command'#3#247#1#8'ShortCut'#3'T@'
|
||||
+#0#1#7'Command'#3'c'#2#8'ShortCut'#3'U`'#0#1#7'Command'#3'\'#2#8'ShortCut'#3
|
||||
+'V@'#0#1#7'Command'#3'['#2#8'ShortCut'#3'X@'#0#1#7'Command'#3#251#1#8'ShortC'
|
||||
+'ut'#3'Y@'#0#1#7'Command'#3#250#1#8'ShortCut'#3'Y`'#0#1#7'Command'#3'Y'#2#8
|
||||
+'ShortCut'#3'Z@'#0#1#7'Command'#3'Z'#2#8'ShortCut'#3'Z`'#0#1#7'Command'#3'-'
|
||||
+#1#8'ShortCut'#3'0@'#0#1#7'Command'#3'.'#1#8'ShortCut'#3'1@'#0#1#7'Command'#3
|
||||
+'/'#1#8'ShortCut'#3'2@'#0#1#7'Command'#3'0'#1#8'ShortCut'#3'3@'#0#1#7'Comman'
|
||||
+'d'#3'1'#1#8'ShortCut'#3'4@'#0#1#7'Command'#3'2'#1#8'ShortCut'#3'5@'#0#1#7'C'
|
||||
+'ommand'#3'3'#1#8'ShortCut'#3'6@'#0#1#7'Command'#3'4'#1#8'ShortCut'#3'7@'#0#1
|
||||
+#7'Command'#3'5'#1#8'ShortCut'#3'8@'#0#1#7'Command'#3'6'#1#8'ShortCut'#3'9@'
|
||||
+#0#1#7'Command'#3'_'#1#8'ShortCut'#3'0`'#0#1#7'Command'#3'`'#1#8'ShortCut'#3
|
||||
+'1`'#0#1#7'Command'#3'a'#1#8'ShortCut'#3'2`'#0#1#7'Command'#3'b'#1#8'ShortCu'
|
||||
+'t'#3'3`'#0#1#7'Command'#3'c'#1#8'ShortCut'#3'4`'#0#1#7'Command'#3'd'#1#8'Sh'
|
||||
+'ortCut'#3'5`'#0#1#7'Command'#3'e'#1#8'ShortCut'#3'6`'#0#1#7'Command'#3'f'#1
|
||||
+#8'ShortCut'#3'7`'#0#1#7'Command'#3'g'#1#8'ShortCut'#3'8`'#0#1#7'Command'#3
|
||||
+'h'#1#8'ShortCut'#3'9`'#0#1#7'Command'#3#231#0#8'ShortCut'#3'N`'#0#1#7'Comma'
|
||||
+'nd'#3#232#0#8'ShortCut'#3'C`'#0#1#7'Command'#3#233#0#8'ShortCut'#3'L`'#0#1#7
|
||||
+'Command'#3'd'#2#8'ShortCut'#2#9#0#1#7'Command'#3'e'#2#8'ShortCut'#3#9' '#0#1
|
||||
+#7'Command'#3#250#0#8'ShortCut'#3'B`'#0#0#13'Lines.Strings'#1#6#8'SynEdit1'#0
|
||||
+#22'SelectedColor.OnChange'#13#0#0#9'TMainMenu'#9'MainMenu1'#4'left'#2'S'#3
|
||||
+'top'#2'='#0#9'TMenuItem'#12'FileMenuItem'#7'Caption'#6#4'File'#0#9'TMenuIte'
|
||||
+'m'#12'OpenMenuItem'#7'Caption'#6#4'Open'#7'OnClick'#7#17'OpenMenuItemClick'
|
||||
+#0#0#9'TMenuItem'#9'MenuItem2'#7'Caption'#6#1'-'#0#0#9'TMenuItem'#12'ExitMen'
|
||||
+'uItem'#7'Caption'#6#4'Exit'#0#0#0#0#11'TOpenDialog'#11'OpenDialog1'#7'Optio'
|
||||
+'ns'#11#15'ofFileMustExist'#14'ofEnableSizing'#12'ofViewDetail'#0#4'left'#3
|
||||
+#135#0#3'top'#2'<'#0#0#0
|
||||
]);
|
||||
71
examples/synpositionhighlighter/unit1.pas
Normal file
71
examples/synpositionhighlighter/unit1.pas
Normal file
@ -0,0 +1,71 @@
|
||||
unit Unit1;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, SynEdit,
|
||||
StdCtrls, Menus, SynHighlighterPosition, SynEditHighlighter;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
MainMenu1: TMainMenu;
|
||||
FileMenuItem: TMenuItem;
|
||||
ExitMenuItem: TMenuItem;
|
||||
OpenMenuItem: TMenuItem;
|
||||
MenuItem2: TMenuItem;
|
||||
OpenDialog1: TOpenDialog;
|
||||
SynEdit1: TSynEdit;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure OpenMenuItemClick(Sender: TObject);
|
||||
private
|
||||
public
|
||||
Highlighter: TSynPositionHighlighter;
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.OpenMenuItemClick(Sender: TObject);
|
||||
begin
|
||||
if not OpenDialog1.Execute then exit;
|
||||
SynEdit1.Lines.LoadFromFile(OpenDialog1.FileName);
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
var
|
||||
Attr1, Attr2: TtkTokenKind;
|
||||
begin
|
||||
// create highlighter
|
||||
Highlighter:=TSynPositionHighlighter.Create(Self);
|
||||
|
||||
// add some attributes
|
||||
Attr1:=Highlighter.CreateTokenID('Attr1',clRed,clNone,[]);
|
||||
Attr2:=Highlighter.CreateTokenID('Attr2',clBlue,clNone,[fsBold]);
|
||||
|
||||
// define
|
||||
Highlighter.AddToken(0,3,Attr1);
|
||||
Highlighter.AddToken(1,2,Attr2);
|
||||
|
||||
// use highlighter
|
||||
SynEdit1.Highlighter:=Highlighter;
|
||||
|
||||
// set some example text
|
||||
SynEdit1.Lines.Text:=
|
||||
'This is some'+LineEnding
|
||||
+'example text.'+LineEnding;
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$I unit1.lrs}
|
||||
|
||||
end.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user