From 174b5519c142333f3c3538170cf828810235ec74 Mon Sep 17 00:00:00 2001 From: martin Date: Sat, 31 Jan 2009 20:19:50 +0000 Subject: [PATCH] Example how to use TSynAnySyn Highlighter. Contributed by Bernd Mueller (see issue #13068) git-svn-id: trunk@18522 - --- .gitattributes | 5 + .../synanysynhighlighter.lpi | 97 ++++ .../synanysynhighlighter.lpr | 18 + examples/synanyhighlighter/unit1.lfm | 483 ++++++++++++++++++ examples/synanyhighlighter/unit1.lrs | 93 ++++ examples/synanyhighlighter/unit1.pas | 106 ++++ 6 files changed, 802 insertions(+) create mode 100644 examples/synanyhighlighter/synanysynhighlighter.lpi create mode 100644 examples/synanyhighlighter/synanysynhighlighter.lpr create mode 100644 examples/synanyhighlighter/unit1.lfm create mode 100644 examples/synanyhighlighter/unit1.lrs create mode 100644 examples/synanyhighlighter/unit1.pas diff --git a/.gitattributes b/.gitattributes index 2d8c7b94c9..ac4eac1554 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2370,6 +2370,11 @@ examples/std_actions/readme.txt svneol=native#text/plain examples/std_actions/unit1.lfm svneol=native#text/plain examples/std_actions/unit1.lrs svneol=native#text/pascal examples/std_actions/unit1.pas svneol=native#text/pascal +examples/synanyhighlighter/synanysynhighlighter.lpi svneol=native#text/plain +examples/synanyhighlighter/synanysynhighlighter.lpr svneol=native#text/plain +examples/synanyhighlighter/unit1.lfm svneol=native#text/plain +examples/synanyhighlighter/unit1.lrs svneol=native#text/plain +examples/synanyhighlighter/unit1.pas svneol=native#text/plain examples/synchronize.pp svneol=native#text/pascal examples/synedit1.lpi svneol=native#text/plain examples/synedit1.pas svneol=native#text/pascal diff --git a/examples/synanyhighlighter/synanysynhighlighter.lpi b/examples/synanyhighlighter/synanysynhighlighter.lpi new file mode 100644 index 0000000000..1f13e76125 --- /dev/null +++ b/examples/synanyhighlighter/synanysynhighlighter.lpi @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/synanyhighlighter/synanysynhighlighter.lpr b/examples/synanyhighlighter/synanysynhighlighter.lpr new file mode 100644 index 0000000000..bf4860e387 --- /dev/null +++ b/examples/synanyhighlighter/synanysynhighlighter.lpr @@ -0,0 +1,18 @@ +program synanysynhighlighter; + +{$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. + diff --git a/examples/synanyhighlighter/unit1.lfm b/examples/synanyhighlighter/unit1.lfm new file mode 100644 index 0000000000..dc86d82a9e --- /dev/null +++ b/examples/synanyhighlighter/unit1.lfm @@ -0,0 +1,483 @@ +object Form1: TForm1 + Left = 294 + Height = 293 + Top = 356 + Width = 556 + ActiveControl = SynMemo + Caption = 'Form1' + ClientHeight = 293 + ClientWidth = 556 + Position = poDesktopCenter + LCLVersion = '0.9.26.1' + object Label1: TLabel + Left = 44 + Height = 14 + Top = 180 + Width = 47 + Caption = 'Keywords' + ParentColor = False + end + object Label2: TLabel + Left = 176 + Height = 14 + Top = 180 + Width = 37 + Caption = 'Objects' + ParentColor = False + end + object Label3: TLabel + Left = 300 + Height = 14 + Top = 180 + Width = 48 + Caption = 'Constants' + ParentColor = False + end + object SynMemo: TSynMemo + Cursor = crIBeam + Left = 16 + Height = 156 + Top = 12 + Width = 524 + Font.Height = -16 + Font.Name = 'courier' + Font.Pitch = fpFixed + Font.Quality = fqNonAntialiased + ParentColor = False + ParentFont = False + TabOrder = 0 + BookMarkOptions.OnChange = nil + Gutter.RightOffset = 0 + Gutter.LeftOffset = 0 + Gutter.ShowCodeFolding = True + Gutter.CodeFoldingWidth = 10 + Gutter.ShowChanges = True + Gutter.ShowLineNumbers = True + Highlighter = SynAnySyn + 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 = ( + 'This example shows, how the the Keywords,' + 'Objects and Constants properties of the class' + 'TSynAnySyn can be controlled at runtime.' + '' + 'Objects: this is a simple test line' + 'Keys: this is another test line' + '' + ) + SelectedColor.OnChange = nil + end + object CheckListBoxKeys: TCheckListBox + Left = 16 + Height = 80 + Top = 200 + Width = 100 + Items.Strings = ( + 'KEYWORDS' + 'OBJECTS' + 'TEST' + 'SIMPLE' + ) + ItemHeight = 13 + OnItemClick = CheckListBoxHandler + TabOrder = 1 + Data = { + 0400000000000000 + } + end + object CheckListBoxObjects: TCheckListBox + Left = 144 + Height = 80 + Top = 200 + Width = 100 + Items.Strings = ( + 'EXAMPLE' + 'CONTROLLED' + 'TSYNANYSYN' + 'ANOTHER' + ) + ItemHeight = 13 + OnItemClick = CheckListBoxHandler + TabOrder = 2 + Data = { + 0400000000000000 + } + end + object CheckListBoxConstants: TCheckListBox + Left = 268 + Height = 80 + Top = 200 + Width = 100 + Items.Strings = ( + 'CLASS' + 'LINE' + 'RUNTIME' + 'THIS' + ) + ItemHeight = 13 + OnItemClick = CheckListBoxHandler + TabOrder = 3 + Data = { + 0400000000000000 + } + end + object ButtonCheckAll: TButton + Left = 384 + Height = 25 + Top = 200 + Width = 75 + Caption = 'Check All' + OnClick = ButtonCheckAllClick + TabOrder = 4 + end + object ButtonUncheckAll: TButton + Left = 384 + Height = 25 + Top = 232 + Width = 75 + Caption = 'Uncheck All' + OnClick = ButtonUncheckAllClick + TabOrder = 5 + end + object SynAnySyn: TSynAnySyn + Enabled = False + CommentAttri.FrameColor = clNone + IdentifierAttri.FrameColor = clNone + IdentifierChars = '!"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÂÃ' + KeyAttri.FrameColor = clNone + ConstantAttri.FrameColor = clNone + ObjectAttri.FrameColor = clNone + EntityAttri.FrameColor = clNone + VariableAttri.FrameColor = clNone + DotAttri.FrameColor = clNone + Objects.Strings = ( + '' + ) + NumberAttri.FrameColor = clNone + PreprocessorAttri.FrameColor = clNone + SpaceAttri.FrameColor = clNone + StringAttri.FrameColor = clNone + SymbolAttri.FrameColor = clNone + left = 512 + top = 180 + end +end diff --git a/examples/synanyhighlighter/unit1.lrs b/examples/synanyhighlighter/unit1.lrs new file mode 100644 index 0000000000..d73fbe05de --- /dev/null +++ b/examples/synanyhighlighter/unit1.lrs @@ -0,0 +1,93 @@ +{ 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'd'#1#5'Wid' + +'th'#3','#2#13'ActiveControl'#7#7'SynMemo'#7'Caption'#6#5'Form1'#12'ClientHe' + +'ight'#3'%'#1#11'ClientWidth'#3','#2#8'Position'#7#15'poDesktopCenter'#10'LC' + +'LVersion'#6#8'0.9.26.1'#0#6'TLabel'#6'Label1'#4'Left'#2','#6'Height'#2#14#3 + +'Top'#3#180#0#5'Width'#2'/'#7'Caption'#6#8'Keywords'#11'ParentColor'#8#0#0#6 + +'TLabel'#6'Label2'#4'Left'#3#176#0#6'Height'#2#14#3'Top'#3#180#0#5'Width'#2 + +'%'#7'Caption'#6#7'Objects'#11'ParentColor'#8#0#0#6'TLabel'#6'Label3'#4'Left' + +#3','#1#6'Height'#2#14#3'Top'#3#180#0#5'Width'#2'0'#7'Caption'#6#9'Constants' + +#11'ParentColor'#8#0#0#8'TSynMemo'#7'SynMemo'#6'Cursor'#7#7'crIBeam'#4'Left' + +#2#16#6'Height'#3#156#0#3'Top'#2#12#5'Width'#3#12#2#11'Font.Height'#2#240#9 + +'Font.Name'#6#7'courier'#10'Font.Pitch'#7#7'fpFixed'#12'Font.Quality'#7#16'f' + +'qNonAntialiased'#11'ParentColor'#8#10'ParentFont'#8#8'TabOrder'#2#0#24'Book' + +'MarkOptions.OnChange'#13#18'Gutter.RightOffset'#2#0#17'Gutter.LeftOffset'#2 + +#0#22'Gutter.ShowCodeFolding'#9#23'Gutter.CodeFoldingWidth'#2#10#18'Gutter.S' + +'howChanges'#9#22'Gutter.ShowLineNumbers'#9#11'Highlighter'#7#9'SynAnySyn'#10 + +'Keystrokes'#14#1#7'Command'#2#3#8'ShortCut'#2'&'#0#1#7'Command'#2'g'#8'Shor' + +'tCut'#3'& '#0#1#7'Command'#3#211#0#8'ShortCut'#3'&@'#0#1#7'Command'#2#4#8'S' + +'hortCut'#2'('#0#1#7'Command'#2'h'#8'ShortCut'#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'S' + +'hortCut'#3'% '#0#1#7'Command'#2#5#8'ShortCut'#3'%@'#0#1#7'Command'#2'i'#8'S' + +'hortCut'#3'%`'#0#1#7'Command'#2#2#8'ShortCut'#2''''#0#1#7'Command'#2'f'#8'S' + +'hortCut'#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'S' + +'hortCut'#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'S' + +'hortCut'#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'S' + +'hortCut'#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'Command'#3'['#2#8'ShortCut'#3'. '#0#1#7'Comman' + +'d'#3#245#1#8'ShortCut'#2#8#0#1#7'Command'#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'ShortCut'#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'Command'#3'b'#2#8'ShortCut'#3'I`'#0#1#7'Comma' + +'nd'#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'ShortCut'#3'Y@'#0#1#7'Command'#3#250#1#8'ShortC' + +'ut'#3'Y`'#0#1#7'Command'#3'Y'#2#8'ShortCut'#3'Z@'#0#1#7'Command'#3'Z'#2#8'S' + +'hortCut'#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'Command'#3'1'#1#8'ShortCut'#3'4@'#0#1#7'Comman' + +'d'#3'2'#1#8'ShortCut'#3'5@'#0#1#7'Command'#3'3'#1#8'ShortCut'#3'6@'#0#1#7'C' + +'ommand'#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'ShortCut'#3'3`'#0#1#7'Command'#3'c'#1#8'ShortCu' + +'t'#3'4`'#0#1#7'Command'#3'd'#1#8'ShortCut'#3'5`'#0#1#7'Command'#3'e'#1#8'Sh' + +'ortCut'#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'Command'#3#232#0#8'ShortCut'#3'C`'#0#1#7'Comm' + +'and'#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')This example shows, how the the Keywords,'#6'-Ob' + +'jects and Constants properties of the class'#6'(TSynAnySyn can be controlle' + +'d at runtime.'#6#0#6'#Objects: this is a simple test line'#6#31'Keys: this ' + +'is another test line'#6#0#0#22'SelectedColor.OnChange'#13#0#0#13'TCheckList' + +'Box'#16'CheckListBoxKeys'#4'Left'#2#16#6'Height'#2'P'#3'Top'#3#200#0#5'Widt' + +'h'#2'd'#13'Items.Strings'#1#6#8'KEYWORDS'#6#7'OBJECTS'#6#4'TEST'#6#6'SIMPLE' + +#0#10'ItemHeight'#2#13#11'OnItemClick'#7#19'CheckListBoxHandler'#8'TabOrder' + ,#2#1#4'Data'#10#8#0#0#0#4#0#0#0#0#0#0#0#0#0#13'TCheckListBox'#19'CheckListBo' + +'xObjects'#4'Left'#3#144#0#6'Height'#2'P'#3'Top'#3#200#0#5'Width'#2'd'#13'It' + +'ems.Strings'#1#6#7'EXAMPLE'#6#10'CONTROLLED'#6#10'TSYNANYSYN'#6#7'ANOTHER'#0 + +#10'ItemHeight'#2#13#11'OnItemClick'#7#19'CheckListBoxHandler'#8'TabOrder'#2 + +#2#4'Data'#10#8#0#0#0#4#0#0#0#0#0#0#0#0#0#13'TCheckListBox'#21'CheckListBoxC' + +'onstants'#4'Left'#3#12#1#6'Height'#2'P'#3'Top'#3#200#0#5'Width'#2'd'#13'Ite' + +'ms.Strings'#1#6#5'CLASS'#6#4'LINE'#6#7'RUNTIME'#6#4'THIS'#0#10'ItemHeight'#2 + +#13#11'OnItemClick'#7#19'CheckListBoxHandler'#8'TabOrder'#2#3#4'Data'#10#8#0 + +#0#0#4#0#0#0#0#0#0#0#0#0#7'TButton'#14'ButtonCheckAll'#4'Left'#3#128#1#6'Hei' + +'ght'#2#25#3'Top'#3#200#0#5'Width'#2'K'#7'Caption'#6#9'Check All'#7'OnClick' + +#7#19'ButtonCheckAllClick'#8'TabOrder'#2#4#0#0#7'TButton'#16'ButtonUncheckAl' + +'l'#4'Left'#3#128#1#6'Height'#2#25#3'Top'#3#232#0#5'Width'#2'K'#7'Caption'#6 + +#11'Uncheck All'#7'OnClick'#7#21'ButtonUncheckAllClick'#8'TabOrder'#2#5#0#0 + +#10'TSynAnySyn'#9'SynAnySyn'#7'Enabled'#8#23'CommentAttri.FrameColor'#7#6'cl' + +'None'#26'IdentifierAttri.FrameColor'#7#6'clNone'#15'IdentifierChars'#6#134 + +'!"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghij' + +'klmnopqrstuvwxyz{|}~'#130#131#133#134#139#160#161#162#163#164#165#166#167 + +#168#169#170#171#172#173#174#175#176#177#178#179#180#181#182#183#184#185#186 + +#187#188#189#190#191#194#195#19'KeyAttri.FrameColor'#7#6'clNone'#24'Constant' + +'Attri.FrameColor'#7#6'clNone'#22'ObjectAttri.FrameColor'#7#6'clNone'#22'Ent' + +'ityAttri.FrameColor'#7#6'clNone'#24'VariableAttri.FrameColor'#7#6'clNone'#19 + +'DotAttri.FrameColor'#7#6'clNone'#15'Objects.Strings'#1#6#0#0#22'NumberAttri' + +'.FrameColor'#7#6'clNone'#28'PreprocessorAttri.FrameColor'#7#6'clNone'#21'Sp' + +'aceAttri.FrameColor'#7#6'clNone'#22'StringAttri.FrameColor'#7#6'clNone'#22 + +'SymbolAttri.FrameColor'#7#6'clNone'#4'left'#3#0#2#3'top'#3#180#0#0#0#0 +]); diff --git a/examples/synanyhighlighter/unit1.pas b/examples/synanyhighlighter/unit1.pas new file mode 100644 index 0000000000..376b832cae --- /dev/null +++ b/examples/synanyhighlighter/unit1.pas @@ -0,0 +1,106 @@ +{ + This example shows, how the the Keywords, Objects and Constants properties of + the class TSynAnySyn can be controlled at runtime. +} +unit Unit1; +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, SynMemo, + SynHighlighterAny, CheckLst, StdCtrls; + +type + + { TForm1 } + + TForm1 = class(TForm) + ButtonUncheckAll: TButton; + ButtonCheckAll: TButton; + CheckListBoxConstants: TCheckListBox; + CheckListBoxObjects: TCheckListBox; + CheckListBoxKeys: TCheckListBox; + Label1: TLabel; + Label2: TLabel; + Label3: TLabel; + SynAnySyn: TSynAnySyn; + SynMemo: TSynMemo; + procedure ButtonCheckAllClick(Sender: TObject); + procedure ButtonUncheckAllClick(Sender: TObject); + procedure CheckListBoxHandler(Sender: TObject; Index: integer); + private + { private declarations } + public + { public declarations } + end; + +var + Form1: TForm1; + +implementation + +{ TForm1 } + +procedure TForm1.CheckListBoxHandler(Sender: TObject; Index: integer); +var + s: TStrings; +begin + if Sender = CheckListBoxKeys then + s:= SynAnySyn.KeyWords + else if Sender = CheckListBoxObjects then + s:= SynAnySyn.Objects + else + s:= SynAnySyn.Constants; + With Sender As TCheckListBox do begin + if Checked[Index] then + s.Add(Items[Index]) + else begin + try + s.Delete(s.IndexOf(Items[Index])); + except + // it is just a demo ;-) + end; + end; + SynMemo.Refresh; + end; +end; + +procedure TForm1.ButtonCheckAllClick(Sender: TObject); +var + i: Integer; +begin + for i:= 0 to 3 do begin + CheckListBoxKeys.Checked[i]:= TRUE; + CheckListBoxObjects.Checked[i]:= TRUE; + CheckListBoxConstants.Checked[i]:= TRUE; + end; + SynAnySyn.KeyWords.Clear; + SynAnySyn.KeyWords.Assign(CheckListBoxKeys.Items); + SynAnySyn.Objects.Clear; + SynAnySyn.Objects.Assign(CheckListBoxObjects.Items); + SynAnySyn.Constants.Clear; + SynAnySyn.Constants.Assign(CheckListBoxConstants.Items); + SynMemo.Refresh; +end; + +procedure TForm1.ButtonUncheckAllClick(Sender: TObject); +var + i: Integer; +begin + for i:= 0 to 3 do begin + CheckListBoxKeys.Checked[i]:= FALSE; + CheckListBoxObjects.Checked[i]:= FALSE; + CheckListBoxConstants.Checked[i]:= FALSE; + end; + SynAnySyn.KeyWords.Clear; + SynAnySyn.Objects.Clear; + SynAnySyn.Constants.Clear; + SynMemo.Refresh; +end; + +initialization + {$I unit1.lrs} + +end. +