extrasyn: Improved test program (sorted highlighters). Sample code in some highlighters.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6221 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2018-03-05 11:18:44 +00:00
parent 72edcdf239
commit d5bc3568c6
87 changed files with 604 additions and 422 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 224 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 335 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 275 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 330 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 224 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 224 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 344 B

View File

@ -540,22 +540,22 @@ end;
function TSynAsmSyn.GetSampleSource: string;
begin
Result := '; x86 assembly sample source'#13#10 +
' CODE SEGMENT BYTE PUBLIC'#13#10 +
' ASSUME CS:CODE'#13#10 +
#13#10 +
' PUSH SS'#13#10 +
' POP DS'#13#10 +
' MOV AX, AABBh'#13#10 +
' MOV BYTE PTR ES:[DI], 255'#13#10 +
' JMP SHORT AsmEnd'#13#10 +
#13#10 +
' welcomeMsg DB ''Hello World'', 0'#13#10 +
#13#10 +
' AsmEnd:'#13#10 +
' MOV AX, 0'#13#10 +
#13#10 +
' CODE ENDS'#13#10 +
Result := '; x86 assembly sample source' + LineEnding +
' CODE SEGMENT BYTE PUBLIC' + LineEnding +
' ASSUME CS:CODE' + LineEnding +
LinEending +
' PUSH SS' + LineEnding +
' POP DS' + LineEnding +
' MOV AX, AABBh' + LineEnding +
' MOV BYTE PTR ES:[DI], 255' + LineEnding +
' JMP SHORT AsmEnd' + LineEnding +
LineEnding +
' welcomeMsg DB ''Hello World'', 0' + LineEnding +
LineEnding +
' AsmEnd:' + LineEnding +
' MOV AX, 0' + LineEnding +
LineEnding +
' CODE ENDS' + LineEnding +
'END';
end;

View File

@ -595,6 +595,14 @@ begin
Result := ['0'..'9', 'a'..'z', 'A'..'Z'] + TSynSpecialChars;
end;
function TSynAWKSyn.GetSampleSource :string;
begin
Result :=
'BEGIN { FS='':''; print "This is the first line\n" }' + LineEnding +
'{ print "LINE",NR,$1 }' + LineEnding +
'END { print "This is the last line\n" }';
end;
function TSynAWKSyn.IsFilterStored: Boolean;
begin
Result := fDefaultFilter <> SYNS_FilterAWK;
@ -605,14 +613,6 @@ begin
Result := SYNS_LangAWK;
end;
function TSynAWKSyn.GetSampleSource :string;
begin
Result :=
'BEGIN { FS='':''; print "This is the first line\n" }' + LineEnding +
'{ print "LINE",NR,$1 }' + LineEnding +
'END { print "This is the last line\n" }';
end;
initialization
RegisterPlaceableHighlighter(TSynAWKSyn);

View File

@ -2198,86 +2198,86 @@ end;
function TSynCobolSyn.GetSampleSource: string;
begin
Result := '000100* This is a sample file to be used to show all TSynCobolSyn''s'#13#10 +
'000200* features.'#13#10 +
'000300* This isn''t a valid COBOL program.'#13#10 +
'000400'#13#10 +
'000500* 1. Supported COBOL features.'#13#10 +
'000600'#13#10 +
'000700* 1.1 Sequence area.'#13#10 +
'000800* First six columns in COBOL are reserved for enumeration'#13#10 +
'000900* of source lines.'#13#10 +
'001000* 1.2 Indicator area.'#13#10 +
'001100* 7th column in COBOL is reserved for special markers like ''*'''#13#10 +
'001200* or ''D''.'#13#10 +
'001300* 1.3 Comment lines.'#13#10 +
'001400* Any line started from ''*'' in 7th column is a comment.'#13#10 +
'001500* No separate word highlighting will be done by the editor.'#13#10 +
'001600* 1.4 Debug lines.'#13#10 +
'001700D Any line started from ''D'' will be treated as containing debug'#13#10 +
'001800D commands. No separate word highlighting will be done'#13#10 +
'001900D by the editor.'#13#10 +
'002000* 1.5 Tag area.'#13#10 +
'002100* Only columns from 8th till 72th can be used for COBOL TAG_AREA'#13#10 +
'002200* program. Columns beyond the 72th one may be used by some TAG_AREA'#13#10 +
'002300* COBOL compilers to tag the code in some internal way. TAG_AREA'#13#10 +
'002400* 1.6 Area A identifiers.'#13#10 +
'002500* In area A (from 8th column till'#13#10 +
'002600* 11th one) you should type only sections''/paragraphs'' names.'#13#10 +
'002700* For example "SOME" is a section name:'#13#10 +
'002800 SOME SECTION.'#13#10 +
'002900* 1.7 Preprocessor directives.'#13#10 +
'003000* For example "COPY" is a preprocessor directive:'#13#10 +
'003100 COPY "PRD-DATA.SEL".'#13#10 +
'003200* 1.8 Key words.'#13#10 +
'003300* For example "ACCEPT" and "AT" are COBOL key words:'#13#10 +
'003400 ACCEPT WS-ENTRY AT 2030.'#13#10 +
'003500* 1.9 Boolean constants.'#13#10 +
'003600* These are "TRUE" and "FALSE" constants. For example:'#13#10 +
'003700 EVALUATE TRUE.'#13#10 +
'003800* 1.10 Numbers.'#13#10 +
'003900* Here are the examples of numbers:'#13#10 +
'004000 01 WSV-TEST-REC.'#13#10 +
'004100 03 WSV-INT-T PIC 9(5) VALUE 12345.'#13#10 +
'004200 03 WSV-PRICES PIC 9(4)V99 COMP-3 VALUE 0000.33. '#13#10 +
'004300 03 WSV-Z-PRICES PIC Z(5)9.99- VALUE -2.12. '#13#10 +
'004400 03 WSV-STORE-DATE PIC 9(4)V99E99 VALUE 0001.33E02.'#13#10 +
'004500* 1.11 Strings.'#13#10 +
'004600* The following types of strings are supported:'#13#10 +
'004700* 1.11.1 Quoted strings.'#13#10 +
'004800 MOVE "The name of field is ""PRODUCT""" TO WS-ERR-MESS.'#13#10 +
'004900 MOVE ''The name of field is ''''PRODUCT'''''' TO WS-ERR-MESS.'#13#10 +
'005000* 1.11.2 Pseudo-text.'#13#10 +
'005100 COPY'#13#10 +
'005200 REPLACING ==+00001== BY +2'#13#10 +
'005300 == 1 == BY -3.'#13#10 +
'005400* 1.11.3 Figurative constants.'#13#10 +
'005500* For example "SPACES" is figurative constant:'#13#10 +
'005600 DISPLAY SPACES UPON CRT.'#13#10 +
'005700* 1.12 Continued lines.'#13#10 +
'005800* Only continued strings are supported. For example:'#13#10 +
'005900 MOVE "The name of figurative constant field is'#13#10 +
'006000-"SPACES" TO WS-ERR-MESS.'#13#10 +
'006100* Or (a single quotation mark in 72th column):'#13#10 +
'005900 MOVE "The name of figurative constant field is ""SPACES"'#13#10 +
'006000-""" TO WS-ERR-MESS.'#13#10 +
'006100'#13#10 +
'006200* 2. Unsupported COBOL features.'#13#10 +
'006300'#13#10 +
'006400* 2.1 Continued lines.'#13#10 +
'006500* Continuation of key words is not supported. For example,'#13#10 +
'006600* the following COBOL code is valid but TSynCobolSyn won''t'#13#10 +
'006700* highlight "VALUE" keyword properly:'#13#10 +
'006800 03 WSV-STORE-DATE PIC 9(4)V99E99 VAL'#13#10 +
'006900-UE 0001.33E02.'#13#10 +
'007000* 2.2 Identifiers started from digits.'#13#10 +
'007100* They are valid in COBOL but won''t be highlighted properly'#13#10 +
'007200* by TSynCobolSyn. For example, "000-main" is a paragraph'#13#10 +
'007300* name and should be highlighted as Area A identifier:'#13#10 +
'007400 000-main.'#13#10 +
'007500* 2.3 Comment entries in optional paragraphs'#13#10 +
'007600* The so called comment-entries in the optional paragraphs'#13#10 +
'007700* of the Identification Division are not supported and won''t'#13#10 +
Result := '000100* This is a sample file to be used to show all TSynCobolSyn''s' + LineEnding +
'000200* features.' + LineEnding +
'000300* This isn''t a valid COBOL program.' + LineEnding +
'000400' + LineEnding +
'000500* 1. Supported COBOL features.' + LineEnding +
'000600' + LineEnding +
'000700* 1.1 Sequence area.' + LineEnding +
'000800* First six columns in COBOL are reserved for enumeration' + LineEnding +
'000900* of source lines.' + LineEnding +
'001000* 1.2 Indicator area.' + LineEnding +
'001100* 7th column in COBOL is reserved for special markers like ''*''' + LineEnding +
'001200* or ''D''.' + LineEnding +
'001300* 1.3 Comment lines.' + LineEnding +
'001400* Any line started from ''*'' in 7th column is a comment.' + LineEnding +
'001500* No separate word highlighting will be done by the editor.' + LineEnding +
'001600* 1.4 Debug lines.' + LineEnding +
'001700D Any line started from ''D'' will be treated as containing debug' + LineEnding +
'001800D commands. No separate word highlighting will be done' + LineEnding +
'001900D by the editor.' + LineEnding +
'002000* 1.5 Tag area.' + LineEnding +
'002100* Only columns from 8th till 72th can be used for COBOL TAG_AREA' + LineEnding +
'002200* program. Columns beyond the 72th one may be used by some TAG_AREA' + LineEnding +
'002300* COBOL compilers to tag the code in some internal way. TAG_AREA' + LineEnding +
'002400* 1.6 Area A identifiers.' + LineEnding +
'002500* In area A (from 8th column till' + LineEnding +
'002600* 11th one) you should type only sections''/paragraphs'' names.' + LineEnding +
'002700* For example "SOME" is a section name:' + LineEnding +
'002800 SOME SECTION.' + LineEnding +
'002900* 1.7 Preprocessor directives.' + LineEnding +
'003000* For example "COPY" is a preprocessor directive:' + LineEnding +
'003100 COPY "PRD-DATA.SEL".' + LineEnding +
'003200* 1.8 Key words.' + LineEnding +
'003300* For example "ACCEPT" and "AT" are COBOL key words:' + LineEnding +
'003400 ACCEPT WS-ENTRY AT 2030.' + LineEnding +
'003500* 1.9 Boolean constants.' + LineEnding +
'003600* These are "TRUE" and "FALSE" constants. For example:' + LineEnding +
'003700 EVALUATE TRUE.' + LineEnding +
'003800* 1.10 Numbers.' + LineEnding +
'003900* Here are the examples of numbers:' + LineEnding +
'004000 01 WSV-TEST-REC.' + LineEnding +
'004100 03 WSV-INT-T PIC 9(5) VALUE 12345.' + LineEnding +
'004200 03 WSV-PRICES PIC 9(4)V99 COMP-3 VALUE 0000.33. ' + LineEnding +
'004300 03 WSV-Z-PRICES PIC Z(5)9.99- VALUE -2.12. ' + LineEnding +
'004400 03 WSV-STORE-DATE PIC 9(4)V99E99 VALUE 0001.33E02.' + LineEnding +
'004500* 1.11 Strings.' + LineEnding +
'004600* The following types of strings are supported:' + LineEnding +
'004700* 1.11.1 Quoted strings.' + LineEnding +
'004800 MOVE "The name of field is ""PRODUCT""" TO WS-ERR-MESS.' + LineEnding +
'004900 MOVE ''The name of field is ''''PRODUCT'''''' TO WS-ERR-MESS.' + LineEnding +
'005000* 1.11.2 Pseudo-text.' + LineEnding +
'005100 COPY' + LineEnding +
'005200 REPLACING ==+00001== BY +2' + LineEnding +
'005300 == 1 == BY -3.' + LineEnding +
'005400* 1.11.3 Figurative constants.' + LineEnding +
'005500* For example "SPACES" is figurative constant:' + LineEnding +
'005600 DISPLAY SPACES UPON CRT.' + LineEnding +
'005700* 1.12 Continued lines.' + LineEnding +
'005800* Only continued strings are supported. For example:' + LineEnding +
'005900 MOVE "The name of figurative constant field is' + LineEnding +
'006000-"SPACES" TO WS-ERR-MESS.' + LineEnding +
'006100* Or (a single quotation mark in 72th column):' + LineEnding +
'005900 MOVE "The name of figurative constant field is ""SPACES"' + LineEnding +
'006000-""" TO WS-ERR-MESS.' + LineEnding +
'006100' + LineEnding +
'006200* 2. Unsupported COBOL features.' + LineEnding +
'006300' + LineEnding +
'006400* 2.1 Continued lines.' + LineEnding +
'006500* Continuation of key words is not supported. For example,' + LineEnding +
'006600* the following COBOL code is valid but TSynCobolSyn won''t' + LineEnding +
'006700* highlight "VALUE" keyword properly:' + LineEnding +
'006800 03 WSV-STORE-DATE PIC 9(4)V99E99 VAL' + LineEnding +
'006900-UE 0001.33E02.' + LineEnding +
'007000* 2.2 Identifiers started from digits.' + LineEnding +
'007100* They are valid in COBOL but won''t be highlighted properly' + LineEnding +
'007200* by TSynCobolSyn. For example, "000-main" is a paragraph' + LineEnding +
'007300* name and should be highlighted as Area A identifier:' + LineEnding +
'007400 000-main.' + LineEnding +
'007500* 2.3 Comment entries in optional paragraphs' + LineEnding +
'007600* The so called comment-entries in the optional paragraphs' + LineEnding +
'007700* of the Identification Division are not supported and won''t' + LineEnding +
'007800* be highlighted properly.';
end;

View File

@ -155,6 +155,7 @@ type
procedure CommentProc;
protected
function GetIdentChars: TSynIdentChars; override;
function GetSampleSource: String; override;
function IsFilterStored: Boolean; override;
public
class function GetLanguageName: string; override;
@ -962,6 +963,43 @@ begin
Result := TSynValidStringChars;
end;
function TSynFortranSyn.GetSampleSource: String;
begin
Result :=
'* euclid.f (FORTRAN 77)' + LineEnding +
'* Find greatest common divisor using the Euclidean algorithm' + LineEnding +
LineEnding +
' PROGRAM EUCLID' + LineEnding +
' PRINT *, ''A?''' + LineEnding +
' READ *, NA' + LineEnding +
' IF (NA.LE.0) THEN' + LineEnding +
' PRINT *, ''A must be a positive integer.''' + LineEnding +
' STOP' + LineEnding +
' END IF' + LineEnding +
' PRINT *, ''B?''' + LineEnding +
' READ *, NB' + LineEnding +
' IF (NB.LE.0) THEN' + LineEnding +
' PRINT *, ''B must be a positive integer.''' + LineEnding +
' STOP' + LineEnding +
' END IF' + LineEnding +
' PRINT *, ''The GCD of'', NA, '' and'', NB, '' is'', NGCD(NA, NB), ''.''' + LineEnding +
' STOP' + LineEnding +
' END' + LineEnding +
LineEnding +
' FUNCTION NGCD(NA, NB)' + LineEnding +
' IA = NA' + LineEnding +
' IB = NB' + LineEnding +
' 1 IF (IB.NE.0) THEN' + LineEnding +
' ITEMP = IA' + LineEnding +
' IA = IB' + LineEnding +
' IB = MOD(ITEMP, IB)' + LineEnding +
' GOTO 1' + LineEnding +
' END IF' + LineEnding +
' NGCD = IA' + LineEnding +
' RETURN' + LineEnding +
' END';
end;
function TSynFortranSyn.IsFilterStored: Boolean;
begin
Result := fDefaultFilter <> SYNS_FilterFortran;

File diff suppressed because it is too large Load Diff

View File

@ -8,11 +8,12 @@ object Form1: TForm1
ClientWidth = 742
Menu = MainMenu1
OnCreate = FormCreate
OnDestroy = FormDestroy
LCLVersion = '1.9.0.0'
inline SynEdit1: TSynEdit
Left = 0
Height = 410
Top = 19
Height = 429
Top = 0
Width = 742
Align = alClient
Font.Height = -13
@ -647,18 +648,6 @@ object Form1: TForm1
end
end
end
object Label1: TLabel
Left = 0
Height = 15
Top = 2
Width = 742
Align = alTop
Alignment = taCenter
BorderSpacing.Top = 2
BorderSpacing.Bottom = 2
Caption = 'Label1'
ParentColor = False
end
object MainMenu1: TMainMenu
left = 152
top = 40

View File

@ -6,7 +6,7 @@ interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
SynEdit, Menus, StdCtrls, SynEditHighlighter,
SynEdit, Menus, StdCtrls, ComCtrls, SynEditHighlighter,
SynHighlighterADSP21xx, SynHighlighterFortran, SynHighlighterFoxpro, SynHighlighterGalaxy, SynHighlighterBaan,
SynHighlighterHaskell, SynHighlighterCache, {SynHighlighterDfm,} SynHighlighterModelica, SynHighlighterCobol,
@ -18,22 +18,23 @@ uses
SynHighlighterST, SynHighlighter8051, SynHighlighterLua, SynHighlighterProlog, SynHighlighterCAC,
SynHighlighterAWK;
// SynHighlighterGeneral;
type
{ TForm1 }
TForm1 = class(TForm)
Label1: TLabel;
MainMenu1: TMainMenu;
MenuItem1: TMenuItem;
SynEdit1: TSynEdit;
procedure MenuClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure MenuClick(Sender: TObject);
private
{ private declarations }
FHighlighters: Array of TSynCustomHighlighter;
FHighlighters: TFPList;
procedure SelectHighlighter(AIndex: Integer);
public
{ public declarations }
end;
var
@ -46,6 +47,27 @@ uses
{$R *.lfm}
const
FORM_CAPTION = 'SyntaxHighlighter Test';
function GetHighlighterCaption(hl: TSynCustomHighlighter): String;
begin
if (hl is TSynUniSyn) and (TSynUniSyn(hl).Info.General.Name <> '') then
Result := TSynUniSyn(hl).Info.General.Name
else
Result := hl.LanguageName;
end;
function CompareHighlighters(p1, p2: Pointer): Integer;
var
s1, s2: String;
begin
s1 := GetHighlighterCaption(TSynCustomHighlighter(p1));
s2 := GetHighlighterCaption(TSynCustomHighlighter(p2));
Result := AnsiCompareText(s1, s2);
end;
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
@ -62,95 +84,107 @@ procedure TForm1.FormCreate(Sender: TObject);
end;
var
i, c :Integer;
item :TMenuItem;
i, c: Integer;
item: TMenuItem;
hl: TSynCustomHighlighter;
begin
SetLength(FHighlighters, 35);
Caption := FORM_CAPTION;
for i:= low(FHighlighters) to high(FHighlighters) do
FHighlighters[i] := Nil;
FHighlighters := TFPList.Create;
FHighlighters[00] := TSynADSP21xxSyn.Create(self);
FHighlighters[01] := TSynFortranSyn.Create(self);
FHighlighters[02] := TSynFoxproSyn.Create(self);
FHighlighters[03] := TSynGalaxySyn.Create(self);
FHighlighters[04] := TSynBaanSyn.Create(self);
FHighlighters[05] := TSynAWKSyn.Create(self);
FHighlighters[06] := TSynHaskellSyn.Create(self);
FHighlighters[07] := TSynCacheSyn.Create(self);
FHighlighters[08] := TSynModelicaSyn.Create(self);
FHighlighters[09] := TSynCobolSyn.Create(self);
FHighlighters[10] := TSynCSSyn.Create(self);
FHighlighters[11] := TSynDmlSyn.Create(self);
FHighlighters[12] := TSynProgressSyn.Create(self);
FHighlighters[13] := TSynEiffelSyn.Create(self);
FHighlighters[14] := TSynGWScriptSyn.Create(self);
FHighlighters[15] := TSynHP48Syn.Create(self);
FHighlighters[16] := TSynVBScriptSyn.Create(self);
FHighlighters[17] := TSynUnrealSyn.Create(self);
FHighlighters[18] := TSynVrml97Syn.Create(self);
FHighlighters[19] := TSynTclTkSyn.Create(self);
FHighlighters[20] := TSynLDRSyn.Create(self);
FHighlighters[21] := TSynRubySyn.Create(self);
FHighlighters[22] := TSynInnoSyn.Create(self);
FHighlighters[23] := TSynAsmSyn.Create(self);
FHighlighters[24] := TSynDOTSyn.Create(self);
FHighlighters[25] := TSynIdlSyn.Create(self);
FHighlighters[26] := TSynKixSyn.Create(self);
FHighlighters[27] := TSynSDDSyn.Create(self);
FHighlighters[28] := TSynSMLSyn.Create(self);
FHighlighters[29] := TSynURISyn.Create(self);
FHighlighters[30] := TSynM3Syn.Create(self);
FHighlighters[31] := TSynRCSyn.Create(self);
FHighlighters[32] := TSynPrologSyn.Create(Self);
FHighlighters[33] := TSynLuaSyn.Create(Self);
FHighlighters[34] := TSyn8051Syn.Create(Self);
FHighlighters[35] := TSynCACSyn.Create(Self);
// extra highlighters
FHighlighters.Add(TSynADSP21xxSyn.Create(self));
FHighlighters.Add(TSynFortranSyn.Create(self));
FHighlighters.Add(TSynFoxproSyn.Create(self));
FHighlighters.Add(TSynGalaxySyn.Create(self));
FHighlighters.Add(TSynBaanSyn.Create(self));
FHighlighters.Add(TSynAWKSyn.Create(self));
FHighlighters.Add(TSynHaskellSyn.Create(self));
FHighlighters.Add(TSynCacheSyn.Create(self));
FHighlighters.Add(TSynModelicaSyn.Create(self));
FHighlighters.Add(TSynCobolSyn.Create(self));
FHighlighters.Add(TSynCSSyn.Create(self));
FHighlighters.Add(TSynDmlSyn.Create(self));
FHighlighters.Add(TSynProgressSyn.Create(self));
FHighlighters.Add(TSynEiffelSyn.Create(self));
FHighlighters.Add(TSynGWScriptSyn.Create(self));
FHighlighters.Add(TSynHP48Syn.Create(self));
FHighlighters.Add(TSynVBScriptSyn.Create(self));
FHighlighters.Add(TSynUnrealSyn.Create(self));
FHighlighters.Add(TSynVrml97Syn.Create(self));
FHighlighters.Add(TSynTclTkSyn.Create(self));
FHighlighters.Add(TSynLDRSyn.Create(self));
FHighlighters.Add(TSynRubySyn.Create(self));
FHighlighters.Add(TSynInnoSyn.Create(self));
FHighlighters.Add(TSynAsmSyn.Create(self));
FHighlighters.Add(TSynDOTSyn.Create(self));
FHighlighters.Add(TSynIdlSyn.Create(self));
FHighlighters.Add(TSynKixSyn.Create(self));
FHighlighters.Add(TSynSDDSyn.Create(self));
FHighlighters.Add(TSynSMLSyn.Create(self));
FHighlighters.Add(TSynURISyn.Create(self));
FHighlighters.Add(TSynM3Syn.Create(self));
FHighlighters.Add(TSynRCSyn.Create(self));
FHighlighters.Add(TSynPrologSyn.Create(Self));
FHighlighters.Add(TSynLuaSyn.Create(Self));
FHighlighters.Add(TSyn8051Syn.Create(Self));
FHighlighters.Add(TSynCACSyn.Create(Self));
FHighlighters.Add(TSynSTSyn.Create(self));
// FHighlighters[06] := TSynGeneralSyn.Create(self);
// FHighlighters[09] := TSynDfmSyn.Create(self);
// FHighlighters[12] := TSynUniSyn.Create(self);
// FHighlighters[12] := TSynCPMSyn.Create(self);
// FHighlighters[30] := TSynMsgSyn.Create(self);
// FHighlighters[36] := TSynSTSyn.Create(self);
// FHighlighters.Add(TSynCPMSyn.Create(self));
// FHighlighters.Add(TSynGeneralSyn.Create(self));
// FHighlighters.Add(TSynDfmSyn.Create(self));
// FHighlighters.Add/TSynUniSyn.Create(self));
// FHighlighters.Add(TSynMsgSyn.Create(self));
for i:= low(FHighlighters) to high(FHighlighters) do
if Assigned(FHighlighters[i]) then begin
SetDefaultColors(FHighlighters[i]);
item := TMenuItem.Create(self);
item.Tag := i+1; //0 = unknown highlighter
FHighlighters.Sort(@CompareHighlighters);
for i:=0 to FHighlighters.Count-1 do begin
hl := TSynCustomHighlighter(FHighlighters[i]);
if Assigned(hl) then begin
SetDefaultColors(hl);
item := TMenuItem.Create(self);
item.Tag := i+1; //0 = unknown highlighter
try
if (FHighlighters[i] is TSynUniSyn) and (TSynUniSyn(FHighlighters[i]).Info.General.Name <> '') then
item.Caption := IntToStr(i) + ' - ' + TSynUniSyn(FHighlighters[i]).Info.General.Name
else
item.Caption := IntToStr(i) + ' - ' + TSynCustomHighlighter(FHighlighters[i]).LanguageName;
item.Caption := Format('%d - %s', [i, GetHighlighterCaption(hl)]);
except
on E : Exception do
ShowMessage(E.Message+LineEnding+' at index '+inttostr(i));
end;
item.Name := FHighlighters[i].ClassName;
// item.Hint := hl.ClassName;
item.OnClick := @MenuClick;
if i > 27 then
WriteLn(I, ' : ',Item.Name,' : ', item.Caption);
MenuItem1.Add(item);
end;
end;
SynEdit1.Highlighter := FHighlighters[12];
Label1.Caption := FHighlighters[12].ClassName;
SelectHighlighter(12);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FHighlighters.Free;
end;
procedure TForm1.MenuClick(Sender: TObject);
var i,c:Integer;
var
i, idx, c:Integer;
begin
c:= ComponentCount-1;
c := ComponentCount-1;
if (Sender is TMenuItem) and (TMenuItem(Sender).Tag > 0) then begin
SynEdit1.Highlighter := FHighlighters[TMenuItem(Sender).Tag-1];
Caption := SynEdit1.Highlighter.LanguageName;
SynEdit1.Text := SynEdit1.Highlighter.SampleSource;
Label1.Caption := Caption;
idx := TMenuItem(Sender).Tag - 1;
SelectHighlighter(idx);
end;
end;
procedure TForm1.SelectHighlighter(AIndex: Integer);
begin
SynEdit1.Highlighter := TSynCustomHighlighter(FHighlighters[AIndex]);
SynEdit1.Text := SynEdit1.Highlighter.SampleSource;
Caption := Format('%s - %s [%s]', [
FORM_CAPTION, SynEdit1.Highlighter.LanguageName, SynEdit1.Highlighter.ClassName
]);
end;
end.

View File

@ -15,7 +15,7 @@
<Description Value="Extra highlighters for synedit"/>
<License Value="MPL GPL dual license."/>
<Version Major="1"/>
<Files Count="36">
<Files Count="39">
<Item1>
<Filename Value="SyneditHighlighters\syneditstrconstextra.pas"/>
<UnitName Value="SynEditStrConstExtra"/>
@ -161,6 +161,18 @@
<Filename Value="SyneditHighlighters\SynHighlighter8051.pas"/>
<UnitName Value="SynHighlighter8051"/>
</Item36>
<Item37>
<Filename Value="SyneditHighlighters\synhighlighteruri.pas"/>
<UnitName Value="SynHighlighterURI"/>
</Item37>
<Item38>
<Filename Value="SyneditHighlighters\synhighlighterst.pas"/>
<UnitName Value="SynHighlighterST"/>
</Item38>
<Item39>
<Filename Value="SyneditHighlighters\synhighlightergeneral.pas"/>
<UnitName Value="SynHighlighterGeneral"/>
</Item39>
</Files>
<RequiredPkgs Count="2">
<Item1>

View File

@ -19,7 +19,8 @@ uses
SynHighlighterModelica, SynHighlighterProgress, SynHighlighterProlog,
SynHighlighterRC, SynHighlighterRuby, SynHighlighterSDD, SynHighlighterSml,
SynHighlighterTclTk, SynHighlighterUnreal, SynHighlighterVBScript,
SynHighlighterVrml97, SynHighlighter8051;
SynHighlighterVrml97, SynHighlighter8051, SynHighlighterURI,
SynHighlighterST, SynHighlighterGeneral;
implementation

View File

@ -6,41 +6,93 @@ interface
uses
Classes, SysUtils,
SynHighlighter8051,
SynHighlighterADSP21xx,
SynHighlighterAsm,
SynHighlighterAWK,
SynHighlighterBaan,
SynHighlighterCAC,
SynHighlighterCache,
SynHighlighterCobol,
// SynHighlighterCPM,
SynHighlighterCS,
SynHighlighterDml,
SynHighlighterDOT,
SynHighlighterEiffel,
SynHighlighterFortran,
SynHighlighterFoxpro,
SynHighlighterGalaxy,
SynHighlighterGWS,
SynHighlighterHaskell,
SynHighlighterHP48,
SynHighlighterIDL,
SynHighlighterInno,
SynHighlighterKix,
SynHighlighterLDraw,
SynHighlighterLua,
SynHighlighterM3,
SynHighlighterModelica,
SynHighlighterProgress,
SynHighlighterProlog,
SynHighlighterRC,
SynHighlighterRuby,
SynHighlighterSDD,
SynHighlighterSml,
SynHighlighterTclTk,
SynHighlighterUnreal,
SynHighlighterVBScript,
SynHighlighterVrml97;
SynHighlighterADSP21xx, SynHighlighterFortran, SynHighlighterFoxpro, SynHighlighterGalaxy, SynHighlighterBaan,
SynHighlighterHaskell, SynHighlighterCache, SynHighlighterCS, SynHighlighterDml, SynHighlighterCAC,
SynHighlighterModelica, SynHighlighterCobol, SynHighlighterTclTk, SynHighlighterHP48, SynHighlighterAWK,
SynHighlighterProgress, SynHighlighterEiffel, SynHighlighterGWS, SynHighlighterDOT, SynHighlighterLDraw,
SynHighlighterVBScript, SynHighlighterUnreal, SynHighlighterVrml97, SynHighlighterSml, SynHighlighterIDL,
SynHighlighterRuby, SynHighlighterInno, SynHighlighterAsm, SynHighlighter8051, SynHighlighterLua,
SynHighlighterKix, SynHighlighterSDD, SynHighlighterProlog, SynHighlighterRC, SynHighlighterM3;
{.$R ImagesPNG.Res}
{.$R ImagesPNG.Res}
{.$R ImagesPNG.Res}
{.$R *.rc}
{.$R Images.rc}
//failed miserably to use rc files they are not linked in lazarus for some reason although if I delete the res file
//from the disk the compiler complains about the missing file.
procedure Register;
implementation
uses LResources;
uses
LResources;
{$R images.res}
procedure Register;
begin
RegisterComponents('SynEdit Highlighters',[TSynADSP21xxSyn, TSynTclTkSyn, TSynRubySyn, TSynDOTSyn, TSynCSSyn,
TSynHaskellSyn, TSynFoxproSyn, TSynInnoSyn, TSynDmlSyn, TSynCACSyn,
TSynModelicaSyn, TSynVrml97Syn, TSynHP48Syn, TSynKixSyn, TSynAWKSyn,
TSynProgressSyn, TSynEiffelSyn, TSynBaanSyn, TSynM3Syn, TSynLDRSyn,
TSynVBScriptSyn, TSynUnrealSyn, TSynSMLSyn, TSynIdlSyn, TSynCobolSyn,
TSynGWScriptSyn, TSynGalaxySyn, TSyn8051Syn, TSynAsmSyn, TSynLuaSyn,
TSynFortranSyn, TSynPrologSyn, TSynSDDSyn, TSynRCSyn, TSynCacheSyn]);
RegisterComponents('SynEdit Highlighters',[
TSyn8051Syn,
TSynADSP21xxSyn,
TSynAsmSyn,
TSynAWKSyn,
TSynBaanSyn,
TSynCacheSyn,
TSynCACSyn,
TSynCobolSyn,
// TSynCPMSyn,
TSynCSSyn,
TSynDmlSyn,
TSynDOTSyn,
TSynEiffelSyn,
TSynFortranSyn,
TSynFoxproSyn,
TSynGalaxySyn,
TSynGWScriptSyn,
TSynHaskellSyn,
TSynHP48Syn,
TSynIdlSyn,
TSynInnoSyn,
TSynKixSyn,
TSynLDRSyn,
TSynLuaSyn,
TSynM3Syn,
TSynModelicaSyn,
TSynProgressSyn,
TSynPrologSyn,
TSynRCSyn,
TSynRubySyn,
TSynSMLSyn,
TSynSDDSyn,
TSynTclTkSyn,
TSynUnrealSyn,
TSynVBScriptSyn,
TSynVrml97Syn
]);
end;
initialization
{$I Images.lrs}
end.