mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 11:19:26 +02:00
MG: added xml and lfm highlighter
git-svn-id: trunk@485 -
This commit is contained in:
parent
e0ecf5bb36
commit
7838853d27
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -44,7 +44,9 @@ components/synedit/synedittextbuffer.pp svneol=native#text/pascal
|
||||
components/synedit/synedittypes.pp svneol=native#text/pascal
|
||||
components/synedit/synhighlightercpp.pp svneol=native#text/pascal
|
||||
components/synedit/synhighlighterhtml.pp svneol=native#text/pascal
|
||||
components/synedit/synhighlighterlfm.pas svneol=native#text/pascal
|
||||
components/synedit/synhighlighterpas.pp svneol=native#text/pascal
|
||||
components/synedit/synhighlighterxml.pas svneol=native#text/pascal
|
||||
components/synedit/syntextdrawer.pp svneol=native#text/pascal
|
||||
debugger/cmdlinedebugger.pp svneol=native#text/pascal
|
||||
debugger/dbgbreakpoint.pp svneol=native#text/pascal
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Don't edit, this file is generated by FPCMake Version 1.1 [2001/11/07]
|
||||
# Don't edit, this file is generated by FPCMake Version 1.1 [2001/11/09]
|
||||
#
|
||||
default: all
|
||||
override PATH:=$(subst \,/,$(PATH))
|
||||
@ -147,7 +147,7 @@ endif
|
||||
PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages)
|
||||
override PACKAGE_NAME=lazarus
|
||||
override PACKAGE_VERSION=0.8
|
||||
override TARGET_UNITS+=syntextdrawer syneditkeycmds synedittypes syneditstrconst syneditsearch syneditmiscprocs syneditmiscclasses synedittextbuffer synedit synedithighlighter synhighlighterpas syncompletion syneditautocomplete synhighlighterhtml synhighlightercpp
|
||||
override TARGET_UNITS+=syntextdrawer syneditkeycmds synedittypes syneditstrconst syneditsearch syneditmiscprocs syneditmiscclasses synedittextbuffer synedit synedithighlighter synhighlighterpas syncompletion syneditautocomplete synhighlighterhtml synhighlightercpp synhighlighterxml synhighlighterlfm
|
||||
override DIST_ZIPNAME=lazarus.synedit.$(ZIPSUFFIX)
|
||||
override COMPILER_OPTIONS+=-gl
|
||||
override COMPILER_UNITDIR+=$(COMPILER_UNITTARGETDIR) ../../lcl/units ../../lcl/units/$(LCLPLATFORM)
|
||||
|
@ -12,7 +12,8 @@ version=0.8
|
||||
units=syntextdrawer syneditkeycmds synedittypes syneditstrconst \
|
||||
syneditsearch syneditmiscprocs syneditmiscclasses synedittextbuffer \
|
||||
synedit synedithighlighter synhighlighterpas syncompletion \
|
||||
syneditautocomplete synhighlighterhtml synhighlightercpp
|
||||
syneditautocomplete synhighlighterhtml synhighlightercpp \
|
||||
synhighlighterxml synhighlighterlfm
|
||||
|
||||
[default]
|
||||
|
||||
|
@ -17,7 +17,8 @@ uses
|
||||
syntextdrawer, syneditkeycmds, synedittypes, syneditstrconst,
|
||||
syneditsearch, syneditmiscprocs, syneditmiscclasses, synedittextbuffer,
|
||||
synedit, synedithighlighter, synhighlighterpas, syncompletion,
|
||||
syneditautocomplete, synhighlighterhtml, synhighlightercpp;
|
||||
syneditautocomplete, synhighlighterhtml, synhighlightercpp, synhighlighterxml,
|
||||
synhighlighterlfm;
|
||||
|
||||
implementation
|
||||
|
||||
@ -26,6 +27,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.8 2001/12/06 10:15:06 lazarus
|
||||
MG: added xml and lfm highlighter
|
||||
|
||||
Revision 1.7 2001/03/19 18:51:57 lazarus
|
||||
MG: added dynhasharray and renamed tsynautocompletion
|
||||
|
||||
|
@ -32,13 +32,23 @@ unit SynEditHighlighter;
|
||||
interface
|
||||
|
||||
uses
|
||||
SysUtils, Classes,
|
||||
{$IFDEF SYN_CLX}
|
||||
kTextDrawer,
|
||||
Types,
|
||||
QGraphics,
|
||||
{$ELSE}
|
||||
Graphics,
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
LCLLinux,
|
||||
{$ELSE}
|
||||
Windows,
|
||||
{$ENDIF}
|
||||
SysUtils, Classes, Graphics, Registry,
|
||||
SynEditTypes, SynEditMiscClasses;
|
||||
Registry,
|
||||
IniFiles,
|
||||
{$ENDIF}
|
||||
SynEditTypes,
|
||||
SynEditMiscClasses;
|
||||
|
||||
{$DEFINE _Gp_MustEnhanceRegistry}
|
||||
{$IFDEF SYN_COMPILER_4_UP}
|
||||
@ -80,16 +90,16 @@ type
|
||||
oldStyle: boolean): boolean; virtual;
|
||||
function LoadFromRegistry(Reg: TBetterRegistry): boolean;
|
||||
function SaveToRegistry(Reg: TBetterRegistry): boolean;
|
||||
function LoadFromFile(Ini : TIniFile): boolean; //DDH 10/16/01
|
||||
function SaveToFile(Ini : TIniFile): boolean; //DDH 10/16/01
|
||||
public
|
||||
property IntegerStyle: integer read GetStyleFromInt write SetStyleFromInt;
|
||||
property Name: string read fName;
|
||||
property OnChange: TNotifyEvent read fOnChange write fOnChange;
|
||||
published
|
||||
property Background: TColor read fBackground write SetBackground
|
||||
// default clNone;
|
||||
stored GetBackgroundColorStored; //mh 2000-10-08
|
||||
property Foreground: TColor read fForeground write SetForeground
|
||||
// default clNone;
|
||||
stored GetForegroundColorStored; //mh 2000-10-08
|
||||
property Style: TFontStyles read fStyle write SetStyle //default [];
|
||||
stored GetFontStyleStored; //mh 2000-10-08
|
||||
@ -108,22 +118,30 @@ const
|
||||
SYN_ATTR_KEYWORD = 2;
|
||||
SYN_ATTR_STRING = 3;
|
||||
SYN_ATTR_WHITESPACE = 4;
|
||||
SYN_ATTR_SYMBOL = 5; //mh 2001-09-13
|
||||
|
||||
type
|
||||
TSynCustomHighlighter = class(TComponent)
|
||||
private
|
||||
fAttributes: TStringList;
|
||||
fAttrChangeHooks: TSynNotifyEventChain;
|
||||
fUpdateCount: integer; //mh 2001-09-13
|
||||
fEnabled: Boolean;
|
||||
fWordBreakChars: TSynIdentChars;
|
||||
procedure SetEnabled(const Value: boolean); //DDH 2001-10-23
|
||||
protected
|
||||
fDefaultFilter: string;
|
||||
fUpdateChange: boolean; //mh 2001-09-13
|
||||
procedure AddAttribute(AAttrib: TSynHighlighterAttributes);
|
||||
procedure DefHighlightChange(Sender: TObject);
|
||||
procedure FreeHighlighterAttributes; //mh 2001-09-13
|
||||
function GetAttribCount: integer; virtual;
|
||||
function GetAttribute(idx: integer): TSynHighlighterAttributes; virtual;
|
||||
function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes;
|
||||
virtual; abstract;
|
||||
function GetDefaultFilter: string; virtual;
|
||||
function GetIdentChars: TSynIdentChars; virtual;
|
||||
procedure SetWordBreakChars(AChars: TSynIdentChars); virtual;
|
||||
function GetSampleSource: string; virtual;
|
||||
function IsFilterStored: boolean; virtual;
|
||||
procedure SetAttributesOnChange(AEvent: TNotifyEvent);
|
||||
@ -141,6 +159,8 @@ type
|
||||
procedure AddSpecialAttribute(const AttribName: string);
|
||||
{$ENDIF}
|
||||
procedure Assign(Source: TPersistent); override;
|
||||
procedure BeginUpdate;
|
||||
procedure EndUpdate;
|
||||
function GetEol: Boolean; virtual; abstract;
|
||||
function GetRange: Pointer; virtual;
|
||||
function GetToken: String; virtual; abstract;
|
||||
@ -153,16 +173,19 @@ type
|
||||
function IsKeyword(const AKeyword: string): boolean; virtual; // DJLP 2000-08-09
|
||||
procedure Next; virtual; abstract;
|
||||
procedure NextToEol;
|
||||
procedure SetLine(const NewValue: String; LineNumber:Integer); virtual; abstract;
|
||||
procedure SetLine({$IFDEF FPC}const {$ENDIF}NewValue: String; LineNumber:Integer); virtual; abstract;
|
||||
procedure SetRange(Value: Pointer); virtual;
|
||||
procedure ResetRange; virtual;
|
||||
function UseUserSettings(settingIndex: integer): boolean; virtual;
|
||||
procedure EnumUserSettings(Settings: TStrings); virtual;
|
||||
function LoadFromRegistry(RootKey: HKEY; Key: string): boolean; virtual;
|
||||
function SaveToRegistry(RootKey: HKEY; Key: string): boolean; virtual;
|
||||
function LoadFromFile(AFileName: String): boolean; //DDH 10/16/01
|
||||
function SaveToFile(AFileName: String): boolean; //DDH 10/16/01
|
||||
procedure HookAttrChangeEvent(ANotifyEvent: TNotifyEvent);
|
||||
procedure UnhookAttrChangeEvent(ANotifyEvent: TNotifyEvent);
|
||||
property IdentChars: TSynIdentChars read GetIdentChars;
|
||||
property WordBreakChars: TSynIdentChars read fWordBreakChars write SetWordBreakChars;
|
||||
property LanguageName: string read GetLanguageName;
|
||||
public
|
||||
property AttrCount: integer read GetAttribCount;
|
||||
@ -178,11 +201,14 @@ type
|
||||
index SYN_ATTR_KEYWORD read GetDefaultAttribute;
|
||||
property StringAttribute: TSynHighlighterAttributes
|
||||
index SYN_ATTR_STRING read GetDefaultAttribute;
|
||||
property SymbolAttribute: TSynHighlighterAttributes //mh 2001-09-13
|
||||
index SYN_ATTR_SYMBOL read GetDefaultAttribute;
|
||||
property WhitespaceAttribute: TSynHighlighterAttributes
|
||||
index SYN_ATTR_WHITESPACE read GetDefaultAttribute;
|
||||
published
|
||||
property DefaultFilter: string read GetDefaultFilter write SetDefaultFilter
|
||||
stored IsFilterStored;
|
||||
property Enabled: boolean read fEnabled write SetEnabled default TRUE; //DDH 2001-10-23
|
||||
end;
|
||||
|
||||
TSynCustomHighlighterClass = class of TSynCustomHighlighter;
|
||||
@ -345,7 +371,6 @@ begin
|
||||
fName := attribName;
|
||||
end;
|
||||
|
||||
{begin} //mh 2000-10-08
|
||||
function TSynHighlighterAttributes.GetBackgroundColorStored: boolean;
|
||||
begin
|
||||
Result := fBackground <> fBackgroundDefault;
|
||||
@ -367,7 +392,6 @@ begin
|
||||
fBackgroundDefault := fBackground;
|
||||
fStyleDefault := fStyle;
|
||||
end;
|
||||
{end} //mh 2000-10-08
|
||||
|
||||
function TSynHighlighterAttributes.LoadFromBorlandRegistry(rootKey: HKEY;
|
||||
attrKey, attrName: string; oldStyle: boolean): boolean;
|
||||
@ -605,6 +629,36 @@ begin
|
||||
Result := false;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributes.LoadFromFile(Ini : TIniFile): boolean; //DDH 10/16/01
|
||||
var
|
||||
S: TStringList;
|
||||
begin
|
||||
S := TStringList.Create;
|
||||
try
|
||||
Ini.ReadSection(Name, S);
|
||||
if S.Count > 0 then
|
||||
begin
|
||||
if S.IndexOf('Background') <> -1 then
|
||||
Background := Ini.ReadInteger(Name, 'Background', clWindow);
|
||||
if S.IndexOf('Foreground') <> -1 then
|
||||
Foreground := Ini.ReadInteger(Name, 'Foreground', clWindowText);
|
||||
if S.IndexOf('Style') <> -1 then
|
||||
IntegerStyle := Ini.ReadInteger(Name, 'Style', 0);
|
||||
Result := true;
|
||||
end else Result := false;
|
||||
finally
|
||||
S.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributes.SaveToFile(Ini : TIniFile): boolean; //DDH 10/16/01
|
||||
begin
|
||||
Ini.WriteInteger(Name, 'Background', Background);
|
||||
Ini.WriteInteger(Name, 'Foreground', Foreground);
|
||||
Ini.WriteInteger(Name, 'Style', IntegerStyle);
|
||||
Result := true;
|
||||
end;
|
||||
|
||||
function TSynHighlighterAttributes.GetStyleFromInt: integer;
|
||||
begin
|
||||
if fsBold in Style then Result:= 1 else Result:= 0;
|
||||
@ -626,6 +680,7 @@ end;
|
||||
constructor TSynCustomHighlighter.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
fWordBreakChars := TSynWordBreakChars;
|
||||
fAttributes := TStringList.Create;
|
||||
fAttributes.Duplicates := dupError;
|
||||
fAttributes.Sorted := TRUE;
|
||||
@ -634,16 +689,40 @@ begin
|
||||
end;
|
||||
|
||||
destructor TSynCustomHighlighter.Destroy;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
for i := fAttributes.Count - 1 downto 0 do
|
||||
TSynHighlighterAttributes(fAttributes.Objects[i]).Free;
|
||||
FreeHighlighterAttributes;
|
||||
fAttributes.Free;
|
||||
fAttrChangeHooks.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TSynCustomHighlighter.BeginUpdate;
|
||||
begin
|
||||
Inc(fUpdateCount);
|
||||
end;
|
||||
|
||||
procedure TSynCustomHighlighter.EndUpdate;
|
||||
begin
|
||||
if fUpdateCount > 0 then begin
|
||||
Dec(fUpdateCount);
|
||||
if (fUpdateCount = 0) and fUpdateChange then begin
|
||||
fUpdateChange := FALSE;
|
||||
DefHighlightChange(Self);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSynCustomHighlighter.FreeHighlighterAttributes;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
if fAttributes <> nil then begin
|
||||
for i := fAttributes.Count - 1 downto 0 do
|
||||
TSynHighlighterAttributes(fAttributes.Objects[i]).Free;
|
||||
fAttributes.Clear;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSynCustomHighlighter.Assign(Source: TPersistent);
|
||||
var
|
||||
Src: TSynCustomHighlighter;
|
||||
@ -667,6 +746,9 @@ begin
|
||||
// assign the sample source text only if same or descendant class
|
||||
if Src is ClassType then
|
||||
SampleSource := Src.SampleSource;
|
||||
fWordBreakChars := Src.WordBreakChars;
|
||||
DefaultFilter := Src.DefaultFilter;
|
||||
Enabled := Src.Enabled;
|
||||
end else
|
||||
inherited Assign(Source);
|
||||
end;
|
||||
@ -685,24 +767,23 @@ function TSynCustomHighlighter.LoadFromRegistry(RootKey: HKEY;
|
||||
Key: string): boolean;
|
||||
var
|
||||
r: TBetterRegistry;
|
||||
{$IFNDEF SYN_LAZARUS}
|
||||
{$IFNDEF FPC}
|
||||
i: integer;
|
||||
{$ENDIF}
|
||||
begin
|
||||
r := TBetterRegistry.Create;
|
||||
try
|
||||
r.RootKey := RootKey;
|
||||
{$IFNDEF SYN_LAZARUS}
|
||||
// ToDo Registry
|
||||
{$IFNDEF FPC}
|
||||
if r.OpenKeyReadOnly(Key) then begin
|
||||
Result := true;
|
||||
for i := 0 to AttrCount-1 do
|
||||
Result := Result and Attribute[i].LoadFromRegistry(r);
|
||||
end
|
||||
else Result := false;
|
||||
{$ELSE}
|
||||
Result:=false;
|
||||
else
|
||||
{$ENDIF}
|
||||
Result := false;
|
||||
|
||||
finally r.Free; end;
|
||||
end;
|
||||
|
||||
@ -724,6 +805,40 @@ begin
|
||||
finally r.Free; end;
|
||||
end;
|
||||
|
||||
function TSynCustomHighlighter.LoadFromFile(AFileName : String): boolean; //DDH 10/16/01
|
||||
VAR AIni : TIniFile;
|
||||
i : Integer;
|
||||
begin
|
||||
AIni := TIniFile.Create(AFileName);
|
||||
try
|
||||
with AIni do
|
||||
begin
|
||||
Result := true;
|
||||
for i := 0 to AttrCount-1 do
|
||||
Result := Result and Attribute[i].LoadFromFile(AIni);
|
||||
end;
|
||||
finally
|
||||
AIni.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSynCustomHighlighter.SaveToFile(AFileName : String): boolean; //DDH 10/16/01
|
||||
var AIni : TIniFile;
|
||||
i: integer;
|
||||
begin
|
||||
AIni := TIniFile.Create(AFileName);
|
||||
try
|
||||
with AIni do
|
||||
begin
|
||||
Result := true;
|
||||
for i := 0 to AttrCount-1 do
|
||||
Result := Result and Attribute[i].SaveToFile(AIni);
|
||||
end;
|
||||
finally
|
||||
AIni.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSynCustomHighlighter.AddAttribute(AAttrib: TSynHighlighterAttributes);
|
||||
begin
|
||||
fAttributes.AddObject(AAttrib.Name, AAttrib);
|
||||
@ -738,7 +853,10 @@ end;
|
||||
|
||||
procedure TSynCustomHighlighter.DefHighlightChange(Sender: TObject);
|
||||
begin
|
||||
fAttrChangeHooks.Fire;
|
||||
if fUpdateCount > 0 then
|
||||
fUpdateChange := TRUE
|
||||
else
|
||||
fAttrChangeHooks.Fire;
|
||||
end;
|
||||
|
||||
function TSynCustomHighlighter.GetAttribCount: integer;
|
||||
@ -770,6 +888,11 @@ begin
|
||||
Result := [#33..#255];
|
||||
end;
|
||||
|
||||
procedure TSynCustomHighlighter.SetWordBreakChars(AChars: TSynIdentChars);
|
||||
begin
|
||||
fWordBreakChars := AChars;
|
||||
end;
|
||||
|
||||
{$IFNDEF SYN_CPPB_1} class {$ENDIF}
|
||||
function TSynCustomHighlighter.GetLanguageName: string;
|
||||
begin
|
||||
@ -822,12 +945,10 @@ var
|
||||
begin
|
||||
for i := fAttributes.Count - 1 downto 0 do begin
|
||||
Attri := TSynHighlighterAttributes(fAttributes.Objects[i]);
|
||||
{begin} //mh 2000-10-08
|
||||
if Attri <> nil then begin
|
||||
Attri.OnChange := AEvent;
|
||||
Attri.InternalSaveDefaultValues;
|
||||
end;
|
||||
{end} //mh 2000-10-08
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -849,6 +970,18 @@ begin
|
||||
fAttrChangeHooks.Remove(ANotifyEvent);
|
||||
end;
|
||||
|
||||
procedure TSynCustomHighlighter.SetEnabled(const Value: boolean);
|
||||
begin
|
||||
if fEnabled <> Value then
|
||||
begin
|
||||
fEnabled := Value;
|
||||
//we need to notify any editor that we are attached to to repaint,
|
||||
//but a highlighter doesn't know what editor it is attached to.
|
||||
//Until this is resolved, you will have to manually call repaint
|
||||
//on the editor in question.
|
||||
end;
|
||||
end;
|
||||
|
||||
{$IFNDEF SYN_CPPB_1}
|
||||
initialization
|
||||
G_PlaceableHighlighters := TSynHighlighterList.Create;
|
||||
|
@ -63,24 +63,32 @@ const
|
||||
SYNS_AttrAsmKey = 'Asm key';
|
||||
SYNS_AttrASP = 'Asp';
|
||||
SYNS_AttrAssembler = 'Assembler';
|
||||
SYNS_AttrAttributeName = 'Attribute Name';
|
||||
SYNS_AttrAttributeValue = 'Attribute Value';
|
||||
SYNS_AttrBlock = 'Block';
|
||||
SYNS_AttrBrackets = 'Brackets';
|
||||
SYNS_AttrCDATASection = 'CDATA Section';
|
||||
SYNS_AttrCharacter = 'Character';
|
||||
SYNS_AttrClass = 'Class';
|
||||
SYNS_AttrComment = 'Comment';
|
||||
SYNS_AttrCondition = 'Condition';
|
||||
SYNS_AttrDataType = 'Data type';
|
||||
SYNS_AttrDefaultPackage = 'Default packages'; // DJLP 2000-08-11
|
||||
SYNS_AttrDefaultPackage = 'Default packages';
|
||||
SYNS_AttrDir = 'Direction';
|
||||
SYNS_AttrDirective = 'Directive';
|
||||
SYNS_AttrDOCTYPESection = 'DOCTYPE Section';
|
||||
SYNS_AttrDocumentation = 'Documentation';
|
||||
SYNS_AttrElementName = 'Element Name';
|
||||
SYNS_AttrEmbedSQL = 'Embedded SQL';
|
||||
SYNS_AttrEmbedText = 'Embedded text';
|
||||
SYNS_AttrEntityReference = 'Entity Reference';
|
||||
SYNS_AttrEscapeAmpersand = 'Escape ampersand';
|
||||
SYNS_AttrEvent = 'Event';
|
||||
SYNS_AttrException = 'Exception';
|
||||
SYNS_AttrFloat = 'Float';
|
||||
SYNS_AttrForm = 'Form';
|
||||
SYNS_AttrFunction = 'Function';
|
||||
SYNS_AttrHexadecimal = 'Hexadecimal';
|
||||
SYNS_AttrIcon = 'Icon reference';
|
||||
SYNS_AttrIdentifier = 'Identifier';
|
||||
SYNS_AttrIllegalChar = 'Illegal char';
|
||||
@ -94,13 +102,17 @@ const
|
||||
SYNS_AttrMarker = 'Marker';
|
||||
SYNS_AttrMessage = 'Message';
|
||||
SYNS_AttrMiscellaneous = 'Miscellaneous';
|
||||
SYNS_AttrNamespaceAttrName = 'Namespace Attribute Name';
|
||||
SYNS_AttrNamespaceAttrValue = 'Namespace Attribute Value';
|
||||
SYNS_AttrNonReservedKeyword = 'Non-reserved keyword';
|
||||
SYNS_AttrNull = 'Null';
|
||||
SYNS_AttrNumber = 'Number';
|
||||
SYNS_AttrOctal = 'Octal';
|
||||
SYNS_AttrOperator = 'Operator';
|
||||
SYNS_AttrPLSQL = 'Reserved word (PL/SQL)'; // DJLP 2000-08-11
|
||||
SYNS_AttrPLSQL = 'Reserved word (PL/SQL)';
|
||||
SYNS_AttrPragma = 'Pragma';
|
||||
SYNS_AttrPreprocessor = 'Preprocessor';
|
||||
SYNS_AttrProcessingInstr = 'Processing Instruction';
|
||||
SYNS_AttrQualifier = 'Qualifier';
|
||||
SYNS_AttrRegister = 'Register';
|
||||
SYNS_AttrReservedWord = 'Reserved word';
|
||||
@ -114,113 +126,134 @@ const
|
||||
SYNS_AttrSection = 'Section';
|
||||
SYNS_AttrSpace = 'Space';
|
||||
SYNS_AttrSpecialVariable = 'Special variable';
|
||||
SYNS_AttrSQLPlus = 'SQL*Plus command'; // DJLP 2000-09-05
|
||||
SYNS_AttrSQLKey = 'SQL keyword';
|
||||
SYNS_AttrSQLPlus = 'SQL*Plus command';
|
||||
SYNS_AttrString = 'String';
|
||||
SYNS_AttrSymbol = 'Symbol';
|
||||
SYNS_AttrSyntaxError = 'SyntaxError';
|
||||
SYNS_AttrSystem = 'System functions and variables';
|
||||
SYNS_AttrSystemValue = 'System value';
|
||||
SYNS_AttrTerminator = 'Terminator';
|
||||
SYNS_AttrText = 'Text';
|
||||
SYNS_AttrUnknownWord = 'Unknown word';
|
||||
SYNS_AttrUser = 'User functions and variables';
|
||||
SYNS_AttrUserFunction = 'User functions';
|
||||
SYNS_AttrValue = 'Value';
|
||||
SYNS_AttrVariable = 'Variable';
|
||||
SYNS_AttrWhitespace = 'Whitespace';
|
||||
|
||||
// names of exporter output formats
|
||||
SYNS_ExporterFormatHTML = 'HTML';
|
||||
SYNS_ExporterFormatRTF = 'RTF';
|
||||
|
||||
// TCustomSynEdit scroll hint window caption
|
||||
SYNS_ScrollInfoFmt = 'Top Line: %d';
|
||||
// SYNS_ScrollInfoFmt = 'Top Line: %d';
|
||||
SYNS_ScrollInfoFmt = '%d - %d'; //DDH 10/16/01
|
||||
SYNS_ScrollInfoFmtTop = 'Top Line: %d';
|
||||
// TSynEditPrintPreview page number
|
||||
SYNS_PreviewScrollInfoFmt = 'Page: %d';
|
||||
|
||||
// strings for property editors etc
|
||||
SYNS_EDuplicateShortcut = 'Shortcut already exists';
|
||||
SYNS_ShortcutNone = '<none>';
|
||||
SYNS_DuplicateShortcutMsg = 'The keystroke "%s" is already assigned to ' +
|
||||
'another editor command.';
|
||||
SYNS_DuplicateShortcutMsg2 = 'The keystroke "%s" is already assigned to ' +
|
||||
'another editor command.'#13#10'The short' +
|
||||
'cut for this item has not been changed.';
|
||||
SYNS_DuplicateShortcutMsg = 'The keystroke "%s" is already assigned ' +
|
||||
'to another editor command. (%s)';
|
||||
SYNS_DuplicateShortcutMsg2 = 'The keystroke "%s" is already assigned ' +
|
||||
'to another editor command.'#13#10'The ' +
|
||||
'shortcut for this item has not been changed.';
|
||||
|
||||
// Filters used for open/save dialog
|
||||
SYNS_FilterPascal = 'Pascal files (*.pas,*.dpr,*.dpk,*.inc)|*.pas;*.dpr;*.dpk;*.inc';
|
||||
SYNS_FilterHP48 = 'HP48 files (*.s,*.sou,*.a,*.hp)|*.s;*.sou;*.a;*.hp';
|
||||
SYNS_FilterCAClipper = 'CA-Clipper files (*.prg, *.ch, *.inc)|*.prg;*.ch;*.inc';
|
||||
SYNS_FilterCPP = 'C++ files (*.cpp,*.h,*.hpp)|*.cpp;*.h;*.hpp';
|
||||
SYNS_FilterJava = 'Java files (*.java)|*.java';
|
||||
SYNS_FilterPerl = 'Perl files (*.pl,*.pm,*.cgi)|*.pl;*.pm;*.cgi';
|
||||
SYNS_FilterPascal = 'Pascal Files (*.pas,*.dpr,*.dpk,*.inc)|*.pas;*.dpr;*.dpk;*.inc';
|
||||
SYNS_FilterHP48 = 'HP48 Files (*.s,*.sou,*.a,*.hp)|*.s;*.sou;*.a;*.hp';
|
||||
SYNS_FilterCAClipper = 'CA-Clipper Files (*.prg,*.ch,*.inc)|*.prg;*.ch;*.inc';
|
||||
SYNS_FilterCORBAIDL = 'CORBA IDL files (*.idl)|*.idl';
|
||||
SYNS_FilterCPM = 'CPM reports (*.rdf,*.rif,*.rmf,*.rxf)|*.rdf;*.rif;*.rmf;*.rxf';
|
||||
SYNS_FilterCPP = 'C++ Files (*.c,*.cpp,*.h,*.hpp)|*.c;*.cpp;*.h;*.hpp';
|
||||
SYNS_FilterJava = 'Java Files (*.java)|*.java';
|
||||
SYNS_FilterPerl = 'Perl Files (*.pl,*.pm,*.cgi)|*.pl;*.pm;*.cgi';
|
||||
SYNS_FilterAWK = 'AWK Script (*.awk)|*.awk';
|
||||
SYNS_FilterHTML = 'HTML Document (*.htm,*.html)|*.htm;*.html';
|
||||
SYNS_FilterVBScript = 'VBScript files (*.vbs)|*.vbs';
|
||||
SYNS_FilterGalaxy = 'Galaxy files (*.gtv,*.galrep,*.txt)|*.gtv;*.galrep;*.txt';
|
||||
SYNS_FilterPython = 'Python files (*.py)|*.py';
|
||||
SYNS_FilterSQL = 'SQL files (*.sql)|*.sql';
|
||||
SYNS_FilterHP = 'HP48 files (*.s,*.sou,*.a,*.hp)|*.S;*.SOU;*.A;*.HP';
|
||||
SYNS_FilterTclTk = 'Tcl/Tk files (*.tcl)|*.tcl';
|
||||
SYNS_FilterVBScript = 'VBScript Files (*.vbs)|*.vbs';
|
||||
SYNS_FilterGalaxy = 'Galaxy Files (*.gtv,*.galrep,*.txt)|*.gtv;*.galrep;*.txt';
|
||||
SYNS_FilterPython = 'Python Files (*.py)|*.py';
|
||||
SYNS_FilterSQL = 'SQL Files (*.sql)|*.sql';
|
||||
SYNS_FilterHP = 'HP48 Files (*.s,*.sou,*.a,*.hp)|*.S;*.SOU;*.A;*.HP';
|
||||
SYNS_FilterTclTk = 'Tcl/Tk Files (*.tcl)|*.tcl';
|
||||
SYNS_FilterRTF = 'Rich Text Format (*.rtf)|*.rtf';
|
||||
SYNS_FilterBatch = 'MS-DOS Batch Files (*.bat)|*.bat';
|
||||
SYNS_FilterDFM = 'Delphi/C++ Builder Form Files (*.dfm)|*.dfm';
|
||||
SYNS_FilterBatch = 'MS-DOS Batch Files (*.bat;*.cmd)|*.bat;*.cmd';
|
||||
SYNS_FilterDFM = 'Borland Form Files (*.dfm;*.xfm)|*.dfm;*.xfm';
|
||||
SYNS_FilterLFM = 'Lazarus Form Files (*.lfm)|*.lfm';
|
||||
SYNS_FilterX86Asm = 'x86 Assembly Files (*.asm)|*.ASM';
|
||||
SYNS_FilterGembase = 'GEMBASE files (*.dml,*.gem)|*.DML;*.GEM';
|
||||
SYNS_FilterGembase = 'GEMBASE Files (*.dml,*.gem)|*.DML;*.GEM';
|
||||
SYNS_FilterINI = 'INI Files (*.ini)|*.ini';
|
||||
SYNS_FilterSML = 'Standard ML Files (*.sml)|*.sml';
|
||||
SYNS_FilterVisualBASIC = 'Visual Basic files (*.bas)|*.bas';
|
||||
SYNS_FilterADSP21xx = 'DSP files (*.dsp,*.inc)|*.DSP;*.INC';
|
||||
SYNS_FilterPHP = 'PHP files (*.php,*.php3,*.phtml,*.inc)|*.php;*.php3;*.phtml;*.inc';
|
||||
SYNS_FilterCache = 'Cache files (*.mac,*.inc,*.int)|*.mac;*.inc;*.int';
|
||||
SYNS_FilterVisualBASIC = 'Visual Basic Files (*.bas)|*.bas';
|
||||
SYNS_FilterADSP21xx = 'DSP Files (*.dsp,*.inc)|*.DSP;*.INC';
|
||||
SYNS_FilterPHP = 'PHP Files (*.php,*.php3,*.phtml,*.inc)|*.php;*.php3;*.phtml;*.inc';
|
||||
SYNS_FilterCache = 'Cache Files (*.mac,*.inc,*.int)|*.mac;*.inc;*.int';
|
||||
SYNS_FilterCSS = 'Cascading Stylesheets (*.css)|*.css';
|
||||
SYNS_FilterJScript = 'Javascript files (*.js)|*.js';
|
||||
SYNS_FilterKIX = 'Kix Scripts (*.kix)|*.kix';
|
||||
SYNS_FilterBaan = 'Baan 4GL files (*.cln)|*.cln';
|
||||
SYNS_FilterJScript = 'Javascript Files (*.js)|*.js';
|
||||
SYNS_FilterKIX = 'KiXtart scripts (*.kix)|*.kix';
|
||||
SYNS_FilterBaan = 'Baan 4GL Files (*.cln)|*.cln';
|
||||
SYNS_FilterFoxpro = 'Foxpro Files (*.prg)|*.prg';
|
||||
SYNS_FilterFortran = 'Fortran Files (*.for)|*.for';
|
||||
SYNS_FilterAsm68HC11 = '68HC11 Assembler files (*.hc11,*.asm,*.asc)|*.HC11;*.ASM;*.ASC';
|
||||
SYNS_FilterAsm68HC11 = '68HC11 Assembler Files (*.hc11,*.asm,*.asc)|*.HC11;*.ASM;*.ASC';
|
||||
SYNS_FilterProgress = 'Progress Files (*.w,*.p,*.i)|*.w;*.p;*.i';
|
||||
SYNS_FilterInno = 'Inno Setup Script files (*.iss)|*.iss';
|
||||
SYNS_FilterModelica = 'Modelica files (*.mo)|*.mo';
|
||||
SYNS_FilterModula3 = 'Modula-3 files (*.m3)|*.m3';
|
||||
SYNS_FilterInno = 'Inno Setup Script Files (*.iss)|*.iss';
|
||||
SYNS_FilterModelica = 'Modelica Files (*.mo)|*.mo';
|
||||
SYNS_FilterModula3 = 'Modula-3 Files (*.m3)|*.m3';
|
||||
SYNS_FilterSDD = 'Semanta DD files (*.sdd)|*.sdd';
|
||||
SYNS_FilterXML = 'XML Document (*.xml,*.xsd,*.xsl,*.xslt,*.dtd)|*.xml;*.xsd;*.xsl;*.xslt;*.dtd';
|
||||
SYNS_FilterGWS = 'GW-TEL Script Files (*.gws)|*.gws';
|
||||
SYNS_FilterSynGenMsgfiles = 'Msg files (*.msg)|*.msg';
|
||||
|
||||
// Language names. Maybe somebody wants them translated / more detailed...
|
||||
SYNS_LangHP48 = 'HP48';
|
||||
SYNS_LangCAClipper = 'CA-Clipper';
|
||||
SYNS_LangCPM = 'COAS Product Manager report';
|
||||
SYNS_LangCPP = 'C++';
|
||||
SYNS_LangJava = 'Java';
|
||||
SYNS_LangPerl = 'Perl';
|
||||
SYNS_LangBatch = 'MS-DOS Batch Language';
|
||||
SYNS_LangDfm = 'Delphi/C++ Builder Form Definitions';
|
||||
SYNS_LangBatch = 'MS-DOS batch language';
|
||||
SYNS_LangDfm = 'Borland Form definition';
|
||||
SYNS_LangLfm = 'Lazarus Form definition';
|
||||
SYNS_LangAWK = 'AWK Script';
|
||||
SYNS_LangHTML = 'HTML Document';
|
||||
SYNS_LangCORBAIDL = 'CORBA IDL';
|
||||
SYNS_LangHTML = 'HTML document';
|
||||
SYNS_LangVBSScript = 'MS VBScript';
|
||||
SYNS_LangGalaxy = 'Galaxy';
|
||||
SYNS_LangGeneral = 'General';
|
||||
SYNS_LangPascal = 'ObjectPascal';
|
||||
SYNS_LangX86Asm = 'x86 Assembly Language';
|
||||
SYNS_LangX86Asm = 'x86 assembly language';
|
||||
SYNS_LangPython = 'Python';
|
||||
SYNS_LangTclTk = 'Tcl/Tk';
|
||||
SYNS_LangSQL = 'SQL';
|
||||
SYNS_LangGembase = 'Gembase';
|
||||
SYNS_LangINI = 'INI files';
|
||||
SYNS_LangINI = 'INI file';
|
||||
SYNS_LangSML = 'Standard ML';
|
||||
SYNS_LangVisualBASIC = 'Visual Basic';
|
||||
SYNS_LangADSP21xx = 'ADSP21xx';
|
||||
SYNS_LangPHP = 'PHP';
|
||||
SYNS_LangSybaseSQL = 'Sybase SQL';
|
||||
SYNS_LangGeneralMulti = 'General Multi-Highlighter';
|
||||
SYNS_LangCache = 'Cache object script';
|
||||
SYNS_LangCSS = 'Cascading Stylesheets';
|
||||
SYNS_LangCache = 'Cache Object script';
|
||||
SYNS_LangCSS = 'Cascading style sheets';
|
||||
SYNS_LangJScript = 'Javascript';
|
||||
SYNS_LangKIX = 'KIX32';
|
||||
SYNS_LangKIX = 'KiXtart script';
|
||||
SYNS_LangBaan = 'Baan 4GL';
|
||||
SYNS_LangFoxpro = 'Foxpro';
|
||||
SYNS_LangFortran = 'Fortran';
|
||||
SYNS_Lang68HC11 = '68HC11 Assembler';
|
||||
SYNS_Lang68HC11 = '68HC11 assembler';
|
||||
SYNS_LangProgress = 'Progress';
|
||||
SYNS_LangInno = 'Inno Setup scripts';
|
||||
SYNS_LangInno = 'Inno Setup script';
|
||||
SYNS_LangModelica = 'Modelica';
|
||||
SYNS_LangModula3 = 'Modula 3';
|
||||
SYNS_LangSDD = 'Semanta data dictionary';
|
||||
SYNS_LangXML = 'XML document';
|
||||
SYNS_LangGWS = 'GW-TEL script';
|
||||
SYNS_LangSynGenMsgfiles = 'SynGen Msg files';
|
||||
SYNS_LangUnreal = 'Unreal';
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
|
@ -41,9 +41,18 @@ unit SynEditTypes;
|
||||
|
||||
interface
|
||||
|
||||
const
|
||||
TSynSpecialChars = ['À'..'Ö', 'Ø'..'ö', 'ø'..'ÿ'];
|
||||
TSynValidStringChars = ['_', '0'..'9', 'A'..'Z', 'a'..'z'] + TSynSpecialChars;
|
||||
TSynWordBreakChars = ['.', ',', ';', ':', '"', '''', '!', '?', '[', ']', '(',
|
||||
')', '{', '}', '^', '-', '=', '+', '*', '/', '\', '|'];
|
||||
|
||||
type
|
||||
TSynIdentChars = set of char;
|
||||
|
||||
//NOTE: This will need to be localized and currently will not work with
|
||||
// MBCS languages like Japanese or Korean.
|
||||
|
||||
PSynSelectionMode = ^TSynSelectionMode;
|
||||
TSynSelectionMode = (smNormal, smLine, smColumn);
|
||||
|
||||
|
@ -218,7 +218,7 @@ type
|
||||
function GetEol: Boolean; override;
|
||||
function GetRange: Pointer; override;
|
||||
function GetTokenID: TtkTokenKind;
|
||||
procedure SetLine(const NewValue: String; LineNumber:Integer); override;
|
||||
procedure SetLine({$IFDEF FPC}const {$ENDIF}NewValue: String; LineNumber:Integer); override;
|
||||
function GetToken: String; override;
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
procedure GetTokenEx(var StartPos, EndPos: integer); override;
|
||||
|
558
components/synedit/synhighlighterlfm.pas
Normal file
558
components/synedit/synhighlighterlfm.pas
Normal file
@ -0,0 +1,558 @@
|
||||
{-------------------------------------------------------------------------------
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.1 (the "License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
the specific language governing rights and limitations under the License.
|
||||
|
||||
The Original Code is: SynHighlighterDfm.pas, released 2000-04-14.
|
||||
The Original Code is based on the dmDfmSyn.pas file from the
|
||||
mwEdit component suite by Martin Waldenburg and other developers, the Initial
|
||||
Author of this file is David H. Muir.
|
||||
All Rights Reserved.
|
||||
|
||||
Contributors to the SynEdit and mwEdit projects are listed in the
|
||||
Contributors.txt file.
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of the
|
||||
GNU General Public License Version 2 or later (the "GPL"), in which case
|
||||
the provisions of the GPL are applicable instead of those above.
|
||||
If you wish to allow use of your version of this file only under the terms
|
||||
of the GPL and not to allow others to use your version of this file
|
||||
under the MPL, indicate your decision by deleting the provisions above and
|
||||
replace them with the notice and other provisions required by the GPL.
|
||||
If you do not delete the provisions above, a recipient may use your version
|
||||
of this file under either the MPL or the GPL.
|
||||
|
||||
$Id$
|
||||
|
||||
You may retrieve the latest version of this file at the SynEdit home page,
|
||||
located at http://SynEdit.SourceForge.net
|
||||
|
||||
Known Issues:
|
||||
-------------------------------------------------------------------------------}
|
||||
{
|
||||
@abstract(Provides a Delphi Form Source highlighter for SynEdit)
|
||||
@author(David Muir <david@loanhead45.freeserve.co.uk>)
|
||||
@created(April 13, 2000)
|
||||
@lastmod(2000-06-23)
|
||||
The SynHighlighterLFM unit provides SynEdit with a Delphi Form Source (.LFM) highlighter.
|
||||
The highlighter formats form source code similar to when forms are viewed as text in the Delphi editor.
|
||||
}
|
||||
unit SynHighlighterLFM;
|
||||
|
||||
{$I SynEdit.inc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
SysUtils, Classes,
|
||||
{$IFDEF SYN_CLX}
|
||||
Qt, QControls, QGraphics,
|
||||
{$ELSE}
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
LCLLinux,
|
||||
{$ELSE}
|
||||
Windows,
|
||||
{$ENDIF}
|
||||
Messages, Controls, Graphics, Registry,
|
||||
{$ENDIF}
|
||||
SynEditTypes, SynEditHighlighter;
|
||||
|
||||
type
|
||||
TtkTokenKind = (tkComment, tkIdentifier, tkKey, tkNull, tkNumber, tkSpace,
|
||||
tkString, tkSymbol, tkUnknown);
|
||||
|
||||
TRangeState = (rsANil, rsComment, rsUnKnown);
|
||||
|
||||
TProcTableProc = procedure of object;
|
||||
|
||||
type
|
||||
TSynLFMSyn = class(TSynCustomHighlighter)
|
||||
private
|
||||
fRange: TRangeState;
|
||||
fLine: PChar;
|
||||
fLineNumber: Integer;
|
||||
fProcTable: array[#0..#255] of TProcTableProc;
|
||||
Run: LongInt;
|
||||
fTokenPos: Integer;
|
||||
FTokenID: TtkTokenKind;
|
||||
fCommentAttri: TSynHighlighterAttributes;
|
||||
fIdentifierAttri: TSynHighlighterAttributes;
|
||||
fKeyAttri: TSynHighlighterAttributes;
|
||||
fNumberAttri: TSynHighlighterAttributes;
|
||||
fSpaceAttri: TSynHighlighterAttributes;
|
||||
fStringAttri: TSynHighlighterAttributes;
|
||||
fSymbolAttri: TSynHighlighterAttributes;
|
||||
procedure AltProc;
|
||||
procedure AsciiCharProc;
|
||||
procedure BraceCloseProc;
|
||||
procedure BraceOpenProc;
|
||||
procedure CommentProc;
|
||||
procedure CRProc;
|
||||
procedure EndProc;
|
||||
procedure IntegerProc;
|
||||
procedure LFProc;
|
||||
procedure NullProc;
|
||||
procedure NumberProc;
|
||||
procedure ObjectProc;
|
||||
procedure InheritedProc;
|
||||
procedure SpaceProc;
|
||||
procedure StringProc;
|
||||
procedure SymbolProc;
|
||||
procedure UnknownProc;
|
||||
procedure MakeMethodTables;
|
||||
protected
|
||||
function GetIdentChars: TSynIdentChars; override;
|
||||
function GetSampleSource: string; override;
|
||||
public
|
||||
{$IFNDEF SYN_CPPB_1} class {$ENDIF} //mh 2000-07-14
|
||||
function GetLanguageName: string; override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes;
|
||||
override;
|
||||
function GetEol: Boolean; override;
|
||||
function GetRange: Pointer; override;
|
||||
function GetTokenID: TtkTokenKind;
|
||||
procedure SetLine({$IFDEF FPC}const {$ENDIF}NewValue: String;
|
||||
LineNumber: Integer); override;
|
||||
function GetToken: String; override;
|
||||
function GetTokenAttribute: TSynHighlighterAttributes; override;
|
||||
function GetTokenKind: integer; override;
|
||||
function GetTokenPos: Integer; override;
|
||||
procedure Next; override;
|
||||
procedure SetRange(Value: Pointer); override;
|
||||
procedure ResetRange; override;
|
||||
property IdentChars;
|
||||
published
|
||||
property CommentAttri: TSynHighlighterAttributes read fCommentAttri
|
||||
write fCommentAttri;
|
||||
property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri
|
||||
write fIdentifierAttri;
|
||||
property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri;
|
||||
property NumberAttri: TSynHighlighterAttributes read fNumberAttri
|
||||
write fNumberAttri;
|
||||
property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri
|
||||
write fSpaceAttri;
|
||||
property StringAttri: TSynHighlighterAttributes read fStringAttri
|
||||
write fStringAttri;
|
||||
end;
|
||||
|
||||
function LoadLFMFile2Strings(const AFile: string; AStrings: TStrings;
|
||||
var WasText: boolean): integer;
|
||||
function SaveStrings2LFMFile(AStrings: TStrings; const AFile: string): integer;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
SynEditStrConst;
|
||||
|
||||
{ A couple of useful Delphi Form functions }
|
||||
|
||||
function LoadLFMFile2Strings(const AFile: string; AStrings: TStrings;
|
||||
var WasText: boolean): integer;
|
||||
var
|
||||
Src, Dest: TStream;
|
||||
{$IFDEF SYN_COMPILER_5_UP}
|
||||
origFormat: TStreamOriginalFormat;
|
||||
{$ENDIF}
|
||||
begin
|
||||
Result := 0;
|
||||
WasText := FALSE;
|
||||
AStrings.Clear;
|
||||
try
|
||||
Src := TFileStream.Create(AFile, fmOpenRead or fmShareDenyWrite);
|
||||
try
|
||||
Dest := TMemoryStream.Create;
|
||||
try
|
||||
{$IFDEF SYN_COMPILER_5_UP}
|
||||
origFormat := sofUnknown; //riceball 2000-11-17
|
||||
ObjectResourceToText(Src, Dest, origFormat);
|
||||
WasText := origFormat = sofText;
|
||||
{$ELSE}
|
||||
ObjectResourceToText(Src, Dest);
|
||||
{$ENDIF}
|
||||
Dest.Seek(0, soFromBeginning);
|
||||
AStrings.LoadFromStream(Dest);
|
||||
finally
|
||||
Dest.Free;
|
||||
end;
|
||||
finally
|
||||
Src.Free;
|
||||
end;
|
||||
except
|
||||
on E: EInOutError do Result := -E.ErrorCode;
|
||||
else Result := -1;
|
||||
end;
|
||||
end;
|
||||
|
||||
function SaveStrings2LFMFile(AStrings: TStrings; const AFile: string): integer;
|
||||
var
|
||||
Src, Dest: TStream;
|
||||
begin
|
||||
Result := 0;
|
||||
try
|
||||
Src := TMemoryStream.Create;
|
||||
try
|
||||
AStrings.SaveToStream(Src);
|
||||
Src.Seek(0, soFromBeginning);
|
||||
Dest := TFileStream.Create(AFile, fmCreate);
|
||||
try
|
||||
ObjectTextToResource(Src, Dest);
|
||||
finally
|
||||
Dest.Free;
|
||||
end;
|
||||
finally
|
||||
Src.Free;
|
||||
end;
|
||||
except
|
||||
on E: EInOutError do Result := -E.ErrorCode;
|
||||
else Result := -1;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TSynLFMSyn }
|
||||
|
||||
procedure TSynLFMSyn.MakeMethodTables;
|
||||
var
|
||||
I: Char;
|
||||
begin
|
||||
for I := #0 to #255 do
|
||||
case I of
|
||||
'#': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}AsciiCharProc;
|
||||
'}': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}BraceCloseProc;
|
||||
'{': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}BraceOpenProc;
|
||||
#13: fProcTable[I] := {$IFDEF FPC}@{$ENDIF}CRProc;
|
||||
'A'..'Z', 'a'..'z', '_':
|
||||
if I in ['e', 'E'] then
|
||||
fProcTable[I] := {$IFDEF FPC}@{$ENDIF}EndProc
|
||||
else if I in ['o', 'O'] then
|
||||
fProcTable[I] := {$IFDEF FPC}@{$ENDIF}ObjectProc
|
||||
else if I in ['i', 'I'] then
|
||||
fProcTable[I] := {$IFDEF FPC}@{$ENDIF}InheritedProc
|
||||
else
|
||||
fProcTable[I] := {$IFDEF FPC}@{$ENDIF}AltProc;
|
||||
'$': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}IntegerProc;
|
||||
#10: fProcTable[I] := {$IFDEF FPC}@{$ENDIF}LFProc;
|
||||
#0: fProcTable[I] := {$IFDEF FPC}@{$ENDIF}NullProc;
|
||||
'0'..'9': fProcTable[I] := {$IFDEF FPC}@{$ENDIF}NumberProc;
|
||||
'(', ')', '/', '=', '<', '>', '.', ',', '[', ']':
|
||||
fProcTable[I] := {$IFDEF FPC}@{$ENDIF}SymbolProc;
|
||||
#1..#9, #11, #12, #14..#32: fProcTable[I] := {$IFDEF FPC}@{$ENDIF}SpaceProc;
|
||||
#39: fProcTable[I] := {$IFDEF FPC}@{$ENDIF}StringProc;
|
||||
else fProcTable[I] := {$IFDEF FPC}@{$ENDIF}UnknownProc;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TSynLFMSyn.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment);
|
||||
fCommentAttri.Style := [fsItalic];
|
||||
AddAttribute(fCommentAttri);
|
||||
fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier);
|
||||
AddAttribute(fIdentifierAttri);
|
||||
fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrKey);
|
||||
fKeyAttri.Style := [fsBold];
|
||||
AddAttribute(fKeyAttri);
|
||||
fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber);
|
||||
AddAttribute(fNumberAttri);
|
||||
fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace);
|
||||
AddAttribute(fSpaceAttri);
|
||||
fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString);
|
||||
AddAttribute(fStringAttri);
|
||||
fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol);
|
||||
AddAttribute(fSymbolAttri);
|
||||
SetAttributesOnChange({$IFDEF FPC}@{$ENDIF}DefHighlightChange);
|
||||
MakeMethodTables;
|
||||
fDefaultFilter := SYNS_FilterLFM;
|
||||
fRange := rsUnknown;
|
||||
end;
|
||||
|
||||
procedure TSynLFMSyn.SetLine({$IFDEF FPC}const {$ENDIF}NewValue: String;
|
||||
LineNumber: Integer);
|
||||
begin
|
||||
fLine := PChar(NewValue);
|
||||
Run := 0;
|
||||
fLineNumber := LineNumber;
|
||||
Next;
|
||||
end;
|
||||
|
||||
procedure TSynLFMSyn.AltProc;
|
||||
begin
|
||||
fTokenID := tkIdentifier;
|
||||
repeat
|
||||
Inc(Run);
|
||||
until not (fLine[Run] in ['_', '0'..'9', 'a'..'z', 'A'..'Z']);
|
||||
end;
|
||||
|
||||
procedure TSynLFMSyn.AsciiCharProc;
|
||||
begin
|
||||
fTokenID := tkString;
|
||||
repeat
|
||||
Inc(Run);
|
||||
until not (fLine[Run] in ['0'..'9']);
|
||||
end;
|
||||
|
||||
procedure TSynLFMSyn.BraceCloseProc;
|
||||
begin
|
||||
inc(Run);
|
||||
fRange := rsUnknown;
|
||||
fTokenId := tkIdentifier;
|
||||
end;
|
||||
|
||||
procedure TSynLFMSyn.BraceOpenProc;
|
||||
begin
|
||||
fRange := rsComment;
|
||||
CommentProc;
|
||||
end;
|
||||
|
||||
procedure TSynLFMSyn.CommentProc;
|
||||
begin
|
||||
fTokenID := tkComment;
|
||||
repeat
|
||||
inc(Run);
|
||||
if fLine[Run] = '}' then begin
|
||||
Inc(Run);
|
||||
fRange := rsUnknown;
|
||||
break;
|
||||
end;
|
||||
until fLine[Run] in [#0, #10, #13];
|
||||
end;
|
||||
|
||||
procedure TSynLFMSyn.CRProc;
|
||||
begin
|
||||
fTokenID := tkSpace;
|
||||
Inc(Run);
|
||||
if (fLine[Run] = #10) then Inc(Run);
|
||||
end;
|
||||
|
||||
procedure TSynLFMSyn.EndProc;
|
||||
begin
|
||||
if (fLine[Run + 1] in ['n', 'N']) and
|
||||
(fLine[Run + 2] in ['d', 'D']) and
|
||||
not (fLine[Run + 3] in ['_', '0'..'9', 'a'..'z', 'A'..'Z'])
|
||||
then begin
|
||||
fTokenID := tkKey;
|
||||
Inc(Run, 3);
|
||||
end else
|
||||
AltProc;
|
||||
end;
|
||||
|
||||
procedure TSynLFMSyn.IntegerProc;
|
||||
begin
|
||||
fTokenID := tkNumber;
|
||||
repeat
|
||||
inc(Run);
|
||||
until not (fLine[Run] in ['0'..'9', 'A'..'F', 'a'..'f']);
|
||||
end;
|
||||
|
||||
procedure TSynLFMSyn.LFProc;
|
||||
begin
|
||||
fTokenID := tkSpace;
|
||||
inc(Run);
|
||||
end;
|
||||
|
||||
procedure TSynLFMSyn.NullProc;
|
||||
begin
|
||||
fTokenID := tkNull;
|
||||
end;
|
||||
|
||||
procedure TSynLFMSyn.NumberProc;
|
||||
begin
|
||||
fTokenID := tkNumber;
|
||||
repeat
|
||||
Inc(Run);
|
||||
if fLine[Run] = '.' then begin
|
||||
if fLine[Run + 1] <> '.' then Inc(Run);
|
||||
break;
|
||||
end;
|
||||
until not (fLine[Run] in ['0'..'9', 'e', 'E']);
|
||||
end;
|
||||
|
||||
procedure TSynLFMSyn.ObjectProc;
|
||||
begin
|
||||
if (fLine[Run + 1] in ['b', 'B']) and
|
||||
(fLine[Run + 2] in ['j', 'J']) and
|
||||
(fLine[Run + 3] in ['e', 'E']) and
|
||||
(fLine[Run + 4] in ['c', 'C']) and
|
||||
(fLine[Run + 5] in ['t', 'T']) and
|
||||
not (fLine[Run + 6] in ['_', '0'..'9', 'a'..'z', 'A'..'Z'])
|
||||
then
|
||||
begin
|
||||
fTokenID := tkKey;
|
||||
Inc(Run, 6);
|
||||
end
|
||||
else
|
||||
AltProc;
|
||||
end;
|
||||
|
||||
procedure TSynLFMSyn.InheritedProc;
|
||||
begin
|
||||
if (fLine[Run + 1] in ['n', 'N']) and
|
||||
(fLine[Run + 2] in ['h', 'H']) and
|
||||
(fLine[Run + 3] in ['e', 'E']) and
|
||||
(fLine[Run + 4] in ['r', 'R']) and
|
||||
(fLine[Run + 5] in ['i', 'I']) and
|
||||
(fLine[Run + 6] in ['t', 'T']) and
|
||||
(fLine[Run + 7] in ['e', 'E']) and
|
||||
(fLine[Run + 8] in ['d', 'D']) and
|
||||
not (fLine[Run + 9] in ['_', '0'..'9', 'a'..'z', 'A'..'Z'])
|
||||
then
|
||||
begin
|
||||
fTokenID := tkKey;
|
||||
Inc(Run, 9);
|
||||
end
|
||||
else
|
||||
AltProc;
|
||||
end;
|
||||
|
||||
procedure TSynLFMSyn.SpaceProc;
|
||||
begin
|
||||
fTokenID := tkSpace;
|
||||
repeat
|
||||
Inc(Run);
|
||||
until (fLine[Run] > #32) or (fLine[Run] in [#0, #10, #13]);
|
||||
end;
|
||||
|
||||
procedure TSynLFMSyn.StringProc;
|
||||
begin
|
||||
fTokenID := tkString;
|
||||
repeat
|
||||
Inc(Run);
|
||||
if fLine[Run] = '''' then begin
|
||||
Inc(Run);
|
||||
if fLine[Run] <> '''' then break
|
||||
end;
|
||||
until fLine[Run] in [#0, #10, #13];
|
||||
end;
|
||||
|
||||
procedure TSynLFMSyn.SymbolProc;
|
||||
begin
|
||||
inc(Run);
|
||||
fTokenID := tkSymbol;
|
||||
end;
|
||||
|
||||
procedure TSynLFMSyn.UnknownProc;
|
||||
begin
|
||||
{$IFDEF SYN_MBCSSUPPORT}
|
||||
if FLine[Run] in LeadBytes then
|
||||
Inc(Run,2)
|
||||
else
|
||||
{$ENDIF}
|
||||
inc(Run);
|
||||
fTokenID := tkUnknown;
|
||||
end;
|
||||
|
||||
procedure TSynLFMSyn.Next;
|
||||
begin
|
||||
fTokenPos := Run;
|
||||
if fRange = rsComment then begin
|
||||
if fLine[Run] = #0 then NullProc
|
||||
else CommentProc;
|
||||
end else
|
||||
fProcTable[fLine[Run]]{$IFDEF FPC}(){$ENDIF};
|
||||
end;
|
||||
|
||||
function TSynLFMSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes;
|
||||
begin
|
||||
case Index of
|
||||
SYN_ATTR_COMMENT: Result := fCommentAttri;
|
||||
SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri;
|
||||
SYN_ATTR_KEYWORD: Result := fKeyAttri;
|
||||
SYN_ATTR_STRING: Result := fStringAttri;
|
||||
SYN_ATTR_WHITESPACE: Result := fSpaceAttri;
|
||||
SYN_ATTR_SYMBOL: Result := fSymbolAttri;
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSynLFMSyn.GetEol: Boolean;
|
||||
begin
|
||||
Result := fTokenId = tkNull;
|
||||
end;
|
||||
|
||||
function TSynLFMSyn.GetRange: Pointer;
|
||||
begin
|
||||
Result := Pointer(fRange);
|
||||
end;
|
||||
|
||||
function TSynLFMSyn.GetTokenID: TtkTokenKind;
|
||||
begin
|
||||
Result := fTokenId;
|
||||
end;
|
||||
|
||||
function TSynLFMSyn.GetToken: String;
|
||||
var
|
||||
Len: LongInt;
|
||||
begin
|
||||
Len := Run - fTokenPos;
|
||||
SetString(Result, (FLine + fTokenPos), Len);
|
||||
end;
|
||||
|
||||
function TSynLFMSyn.GetTokenAttribute: TSynHighlighterAttributes;
|
||||
begin
|
||||
case fTokenID of
|
||||
tkComment: Result := fCommentAttri;
|
||||
tkIdentifier: Result := fIdentifierAttri;
|
||||
tkKey: Result := fKeyAttri;
|
||||
tkNumber: Result := fNumberAttri;
|
||||
tkSpace: Result := fSpaceAttri;
|
||||
tkString: Result := fStringAttri;
|
||||
tkSymbol: Result := fSymbolAttri;
|
||||
tkUnknown: Result := fIdentifierAttri;
|
||||
else Result := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSynLFMSyn.GetTokenKind: integer;
|
||||
begin
|
||||
Result := Ord(fTokenID);
|
||||
end;
|
||||
|
||||
function TSynLFMSyn.GetTokenPos: Integer;
|
||||
begin
|
||||
Result := fTokenPos;
|
||||
end;
|
||||
|
||||
procedure TSynLFMSyn.ResetRange;
|
||||
begin
|
||||
fRange := rsUnknown;
|
||||
end;
|
||||
|
||||
procedure TSynLFMSyn.SetRange(Value: Pointer);
|
||||
begin
|
||||
fRange := TRangeState(Value);
|
||||
end;
|
||||
|
||||
function TSynLFMSyn.GetIdentChars: TSynIdentChars;
|
||||
begin
|
||||
Result := TSynValidStringChars;
|
||||
end;
|
||||
|
||||
{$IFNDEF SYN_CPPB_1} class {$ENDIF} //mh 2000-07-14
|
||||
function TSynLFMSyn.GetLanguageName: string;
|
||||
begin
|
||||
Result := SYNS_LangLFM;
|
||||
end;
|
||||
|
||||
function TSynLFMSyn.GetSampleSource: string;
|
||||
begin
|
||||
Result := '{ Delphi/C++ Builder Form Definitions }'#13#10 +
|
||||
'object TestForm: TTestForm'#13#10 +
|
||||
' Left = 273'#13#10 +
|
||||
' Top = 103'#13#10 +
|
||||
' Caption = ''SynEdit sample source'''#13#10 +
|
||||
'end';
|
||||
end; { GetSampleSource }
|
||||
|
||||
{$IFNDEF SYN_CPPB_1} //mh 2000-07-14
|
||||
initialization
|
||||
RegisterPlaceableHighlighter(TSynLFMSyn);
|
||||
{$ENDIF}
|
||||
end.
|
@ -1073,8 +1073,6 @@ begin
|
||||
fRange := rsUnknown;
|
||||
fAsmStart := False;
|
||||
fDefaultFilter := SYNS_FilterPascal;
|
||||
|
||||
|
||||
end; { Create }
|
||||
|
||||
procedure TSynPasSyn.SetLine(const NewValue: string; LineNumber:Integer);
|
||||
@ -1134,7 +1132,7 @@ begin
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
until (Run>fLineLen) or (fLine[Run] in [#0, #10, #13]);
|
||||
{$ELSE}
|
||||
until (Run>fLineLen) or (fLine[Run] in [#0, #10, #13]);
|
||||
until (fLine[Run] in [#0, #10, #13]);
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
|
897
components/synedit/synhighlighterxml.pas
Normal file
897
components/synedit/synhighlighterxml.pas
Normal file
@ -0,0 +1,897 @@
|
||||
{-------------------------------------------------------------------------------
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.1 (the "License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
the specific language governing rights and limitations under the License.
|
||||
|
||||
The Original Code is: SynHighlighterXML.pas, released 2000-11-20.
|
||||
The Initial Author of this file is Jeff Rafter.
|
||||
All Rights Reserved.
|
||||
|
||||
Contributors to the SynEdit and mwEdit projects are listed in the
|
||||
Contributors.txt file.
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of the
|
||||
GNU General Public License Version 2 or later (the "GPL"), in which case
|
||||
the provisions of the GPL are applicable instead of those above.
|
||||
If you wish to allow use of your version of this file only under the terms
|
||||
of the GPL and not to allow others to use your version of this file
|
||||
under the MPL, indicate your decision by deleting the provisions above and
|
||||
replace them with the notice and other provisions required by the GPL.
|
||||
If you do not delete the provisions above, a recipient may use your version
|
||||
of this file under either the MPL or the GPL.
|
||||
|
||||
$Id$
|
||||
|
||||
You may retrieve the latest version of this file at the SynEdit home page,
|
||||
located at http://SynEdit.SourceForge.net
|
||||
|
||||
History:
|
||||
-------------------------------------------------------------------------------
|
||||
2000-11-30 Removed mHashTable and MakeIdentTable per Michael Hieke
|
||||
|
||||
Known Issues:
|
||||
- Nothing is really constrained (properly) to valid name chars
|
||||
- Entity Refs are not constrained to valid name chars
|
||||
- Support for "Combining Chars and Extender Chars" in names are lacking
|
||||
- The internal DTD is not parsed (and not handled correctly)
|
||||
-------------------------------------------------------------------------------}
|
||||
|
||||
{
|
||||
@abstract(Provides an XML highlighter for SynEdit)
|
||||
@author(Jeff Rafter-- Phil 4:13, based on SynHighlighterHTML by Hideo Koiso)
|
||||
@created(2000-11-17)
|
||||
@lastmod(2001-03-12)
|
||||
The SynHighlighterXML unit provides SynEdit with an XML highlighter.
|
||||
}
|
||||
|
||||
unit SynHighlighterXML;
|
||||
|
||||
interface
|
||||
|
||||
{$I SynEdit.inc}
|
||||
|
||||
uses
|
||||
SysUtils, Classes,
|
||||
{$IFDEF SYN_CLX}
|
||||
Qt, QControls, QGraphics,
|
||||
{$ELSE}
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
LCLLinux,
|
||||
{$ELSE}
|
||||
Windows,
|
||||
{$ENDIF}
|
||||
Messages, Controls, Graphics, Registry,
|
||||
{$ENDIF}
|
||||
SynEditTypes, SynEditHighlighter;
|
||||
|
||||
type
|
||||
TtkTokenKind = (tkAposAttrValue, tkAposEntityRef, tkAttribute, tkCDATA,
|
||||
tkComment, tkElement, tkEntityRef, tkEqual, tkNull, tkProcessingInstruction,
|
||||
tkQuoteAttrValue, tkQuoteEntityRef, tkSpace, tkSymbol, tkText,
|
||||
//
|
||||
tknsAposAttrValue, tknsAposEntityRef, tknsAttribute, tknsEqual,
|
||||
tknsQuoteAttrValue, tknsQuoteEntityRef,
|
||||
//These are unused at the moment
|
||||
tkDocType
|
||||
{tkDocTypeAposAttrValue, tkDocTypeAposEntityRef, tkDocTypeAttribute,
|
||||
tkDocTypeElement, tkDocTypeEqual tkDocTypeQuoteAttrValue,
|
||||
tkDocTypeQuoteEntityRef}
|
||||
);
|
||||
|
||||
TRangeState = (rsAposAttrValue, rsAPosEntityRef, rsAttribute, rsCDATA,
|
||||
rsComment, rsElement, rsEntityRef, rsEqual, rsProcessingInstruction,
|
||||
rsQuoteAttrValue, rsQuoteEntityRef, rsText,
|
||||
//
|
||||
rsnsAposAttrValue, rsnsAPosEntityRef, rsnsEqual, rsnsQuoteAttrValue,
|
||||
rsnsQuoteEntityRef,
|
||||
//These are unused at the moment
|
||||
rsDocType, rsDocTypeSquareBraces //ek 2001-11-11
|
||||
{rsDocTypeAposAttrValue, rsDocTypeAposEntityRef, rsDocTypeAttribute,
|
||||
rsDocTypeElement, rsDocTypeEqual, rsDocTypeQuoteAttrValue,
|
||||
rsDocTypeQuoteEntityRef}
|
||||
);
|
||||
|
||||
TProcTableProc = procedure of object;
|
||||
|
||||
TSynXMLSyn = class(TSynCustomHighlighter)
|
||||
private
|
||||
fRange: TRangeState;
|
||||
fLine: PChar;
|
||||
Run: Longint;
|
||||
fTokenPos: Integer;
|
||||
fTokenID: TtkTokenKind;
|
||||
fLineNumber: Integer;
|
||||
fElementAttri: TSynHighlighterAttributes;
|
||||
fSpaceAttri: TSynHighlighterAttributes;
|
||||
fTextAttri: TSynHighlighterAttributes;
|
||||
fEntityRefAttri: TSynHighlighterAttributes;
|
||||
fProcessingInstructionAttri: TSynHighlighterAttributes;
|
||||
fCDATAAttri: TSynHighlighterAttributes;
|
||||
fCommentAttri: TSynHighlighterAttributes;
|
||||
fDocTypeAttri: TSynHighlighterAttributes;
|
||||
fAttributeAttri: TSynHighlighterAttributes;
|
||||
fnsAttributeAttri: TSynHighlighterAttributes;
|
||||
fAttributeValueAttri: TSynHighlighterAttributes;
|
||||
fnsAttributeValueAttri: TSynHighlighterAttributes;
|
||||
fSymbolAttri: TSynHighlighterAttributes;
|
||||
fProcTable: array[#0..#255] of TProcTableProc;
|
||||
FWantBracesParsed: Boolean;
|
||||
procedure NullProc;
|
||||
procedure CarriageReturnProc;
|
||||
procedure LineFeedProc;
|
||||
procedure SpaceProc;
|
||||
procedure LessThanProc;
|
||||
procedure GreaterThanProc;
|
||||
procedure CommentProc;
|
||||
procedure ProcessingInstructionProc;
|
||||
procedure DocTypeProc;
|
||||
procedure CDATAProc;
|
||||
procedure TextProc;
|
||||
procedure ElementProc;
|
||||
procedure AttributeProc;
|
||||
procedure QAttributeValueProc;
|
||||
procedure AAttributeValueProc;
|
||||
procedure EqualProc;
|
||||
procedure IdentProc;
|
||||
procedure MakeMethodTables;
|
||||
function NextTokenIs(T: String): Boolean;
|
||||
procedure EntityRefProc;
|
||||
procedure QEntityRefProc;
|
||||
procedure AEntityRefProc;
|
||||
protected
|
||||
function GetIdentChars: TSynIdentChars; override;
|
||||
function GetSampleSource : String; override;
|
||||
public
|
||||
{$IFNDEF SYN_CPPB_1} class {$ENDIF}
|
||||
function GetLanguageName: string; override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes;
|
||||
override;
|
||||
function GetEol: Boolean; override;
|
||||
function GetRange: Pointer; override;
|
||||
function GetTokenID: TtkTokenKind;
|
||||
procedure SetLine({$IFDEF FPC}const {$ENDIF}NewValue: string; LineNumber:Integer); override;
|
||||
function GetToken: string; override;
|
||||
function GetTokenAttribute: TSynHighlighterAttributes; override;
|
||||
function GetTokenKind: integer; override;
|
||||
function GetTokenPos: Integer; override;
|
||||
procedure Next; override;
|
||||
procedure SetRange(Value: Pointer); override;
|
||||
procedure ReSetRange; override;
|
||||
property IdentChars;
|
||||
published
|
||||
property ElementAttri: TSynHighlighterAttributes read fElementAttri
|
||||
write fElementAttri;
|
||||
property AttributeAttri: TSynHighlighterAttributes read fAttributeAttri
|
||||
write fAttributeAttri;
|
||||
property NamespaceAttributeAttri: TSynHighlighterAttributes
|
||||
read fnsAttributeAttri write fnsAttributeAttri;
|
||||
property AttributeValueAttri: TSynHighlighterAttributes
|
||||
read fAttributeValueAttri write fAttributeValueAttri;
|
||||
property NamespaceAttributeValueAttri: TSynHighlighterAttributes
|
||||
read fnsAttributeValueAttri write fnsAttributeValueAttri;
|
||||
property TextAttri: TSynHighlighterAttributes read fTextAttri
|
||||
write fTextAttri;
|
||||
property CDATAAttri: TSynHighlighterAttributes read fCDATAAttri
|
||||
write fCDATAAttri;
|
||||
property EntityRefAttri: TSynHighlighterAttributes read fEntityRefAttri
|
||||
write fEntityRefAttri;
|
||||
property ProcessingInstructionAttri: TSynHighlighterAttributes
|
||||
read fProcessingInstructionAttri write fProcessingInstructionAttri;
|
||||
property CommentAttri: TSynHighlighterAttributes read fCommentAttri
|
||||
write fCommentAttri;
|
||||
property DocTypeAttri: TSynHighlighterAttributes read fDocTypeAttri
|
||||
write fDocTypeAttri;
|
||||
property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri
|
||||
write fSpaceAttri;
|
||||
property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri
|
||||
write fSymbolAttri;
|
||||
property WantBracesParsed : Boolean read FWantBracesParsed
|
||||
write FWantBracesParsed default True;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
SynEditStrConst;
|
||||
|
||||
const
|
||||
NameChars : set of char = ['0'..'9', 'a'..'z', 'A'..'Z', '_', '.', ':', '-'];
|
||||
|
||||
constructor TSynXMLSyn.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
|
||||
fElementAttri:= TSynHighlighterAttributes.Create(SYNS_AttrElementName);
|
||||
fTextAttri:= TSynHighlighterAttributes.Create(SYNS_AttrText);
|
||||
fSpaceAttri:= TSynHighlighterAttributes.Create(SYNS_AttrWhitespace);
|
||||
fEntityRefAttri:= TSynHighlighterAttributes.Create(SYNS_AttrEntityReference);
|
||||
fProcessingInstructionAttri:= TSynHighlighterAttributes.Create(
|
||||
SYNS_AttrProcessingInstr);
|
||||
fCDATAAttri:= TSynHighlighterAttributes.Create(SYNS_AttrCDATASection);
|
||||
fCommentAttri:= TSynHighlighterAttributes.Create(SYNS_AttrComment);
|
||||
fDocTypeAttri:= TSynHighlighterAttributes.Create(SYNS_AttrDOCTYPESection);
|
||||
fAttributeAttri:= TSynHighlighterAttributes.Create(SYNS_AttrAttributeName);
|
||||
fnsAttributeAttri:= TSynHighlighterAttributes.Create(
|
||||
SYNS_AttrNamespaceAttrName);
|
||||
fAttributeValueAttri:= TSynHighlighterAttributes.Create(
|
||||
SYNS_AttrAttributeValue);
|
||||
fnsAttributeValueAttri:= TSynHighlighterAttributes.Create(
|
||||
SYNS_AttrNamespaceAttrValue);
|
||||
fSymbolAttri:= TSynHighlighterAttributes.Create(SYNS_AttrSymbol);
|
||||
|
||||
fElementAttri.Foreground:= clMaroon;
|
||||
fElementAttri.Style:= [fsBold];
|
||||
|
||||
fDocTypeAttri.Foreground:= clblue;
|
||||
fDocTypeAttri.Style:= [fsItalic];
|
||||
|
||||
fCDATAAttri.Foreground:= clOlive;
|
||||
fCDATAAttri.Style:= [fsItalic];
|
||||
|
||||
fEntityRefAttri.Foreground:= clblue;
|
||||
fEntityRefAttri.Style:= [fsbold];
|
||||
|
||||
fProcessingInstructionAttri.Foreground:= clblue;
|
||||
fProcessingInstructionAttri.Style:= [];
|
||||
|
||||
fTextAttri.Foreground:= clBlack;
|
||||
fTextAttri.Style:= [fsBold];
|
||||
|
||||
fAttributeAttri.Foreground:= clMaroon;
|
||||
fAttributeAttri.Style:= [];
|
||||
|
||||
fnsAttributeAttri.Foreground:= clRed;
|
||||
fnsAttributeAttri.Style:= [];
|
||||
|
||||
fAttributeValueAttri.Foreground:= clNavy;
|
||||
fAttributeValueAttri.Style:= [fsBold];
|
||||
|
||||
fnsAttributeValueAttri.Foreground:= clRed;
|
||||
fnsAttributeValueAttri.Style:= [fsBold];
|
||||
|
||||
fCommentAttri.Background:= clSilver;
|
||||
fCommentAttri.Foreground:= clGray;
|
||||
fCommentAttri.Style:= [fsbold, fsItalic];
|
||||
|
||||
fSymbolAttri.Foreground:= clblue;
|
||||
fSymbolAttri.Style:= [];
|
||||
|
||||
AddAttribute(fSymbolAttri);
|
||||
AddAttribute(fProcessingInstructionAttri);
|
||||
AddAttribute(fDocTypeAttri);
|
||||
AddAttribute(fCommentAttri);
|
||||
AddAttribute(fElementAttri);
|
||||
AddAttribute(fAttributeAttri);
|
||||
AddAttribute(fnsAttributeAttri);
|
||||
AddAttribute(fAttributeValueAttri);
|
||||
AddAttribute(fnsAttributeValueAttri);
|
||||
AddAttribute(fEntityRefAttri);
|
||||
AddAttribute(fCDATAAttri);
|
||||
AddAttribute(fSpaceAttri);
|
||||
AddAttribute(fTextAttri);
|
||||
|
||||
SetAttributesOnChange({$IFDEF FPC}@{$ENDIF}DefHighlightChange);
|
||||
|
||||
MakeMethodTables;
|
||||
fRange := rsText;
|
||||
fDefaultFilter := SYNS_FilterXML;
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.MakeMethodTables;
|
||||
var
|
||||
i: Char;
|
||||
begin
|
||||
for i:= #0 To #255 do begin
|
||||
case i of
|
||||
#0:
|
||||
begin
|
||||
fProcTable[i] := {$IFDEF FPC}@{$ENDIF}NullProc;
|
||||
end;
|
||||
#10:
|
||||
begin
|
||||
fProcTable[i] := {$IFDEF FPC}@{$ENDIF}LineFeedProc;
|
||||
end;
|
||||
#13:
|
||||
begin
|
||||
fProcTable[i] := {$IFDEF FPC}@{$ENDIF}CarriageReturnProc;
|
||||
end;
|
||||
#1..#9, #11, #12, #14..#32:
|
||||
begin
|
||||
fProcTable[i] := {$IFDEF FPC}@{$ENDIF}SpaceProc;
|
||||
end;
|
||||
'<':
|
||||
begin
|
||||
fProcTable[i] := {$IFDEF FPC}@{$ENDIF}LessThanProc;
|
||||
end;
|
||||
'>':
|
||||
begin
|
||||
fProcTable[i] := {$IFDEF FPC}@{$ENDIF}GreaterThanProc;
|
||||
end;
|
||||
else
|
||||
fProcTable[i] := {$IFDEF FPC}@{$ENDIF}IdentProc;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.SetLine({$IFDEF FPC}const {$ENDIF}NewValue: string;
|
||||
LineNumber:Integer);
|
||||
begin
|
||||
fLine := PChar(NewValue);
|
||||
Run := 0;
|
||||
fLineNumber := LineNumber;
|
||||
Next;
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.NullProc;
|
||||
begin
|
||||
fTokenID := tkNull;
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.CarriageReturnProc;
|
||||
begin
|
||||
fTokenID := tkSpace;
|
||||
Inc(Run);
|
||||
if fLine[Run] = #10 then Inc(Run);
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.LineFeedProc;
|
||||
begin
|
||||
fTokenID := tkSpace;
|
||||
Inc(Run);
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.SpaceProc;
|
||||
begin
|
||||
Inc(Run);
|
||||
fTokenID := tkSpace;
|
||||
while fLine[Run] <= #32 do begin
|
||||
if fLine[Run] in [#0, #9, #10, #13] then break;
|
||||
Inc(Run);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.LessThanProc;
|
||||
begin
|
||||
Inc(Run);
|
||||
if (fLine[Run] = '/') then
|
||||
Inc(Run);
|
||||
|
||||
if (fLine[Run] = '!') then
|
||||
begin
|
||||
if NextTokenIs('--') then begin
|
||||
fTokenID := tkSymbol;
|
||||
fRange := rsComment;
|
||||
Inc(Run, 3);
|
||||
end else if NextTokenIs('DOCTYPE') then begin
|
||||
fTokenID := tkDocType;
|
||||
fRange := rsDocType;
|
||||
Inc(Run, 7);
|
||||
end else if NextTokenIs('[CDATA[') then begin
|
||||
fTokenID := tkCDATA;
|
||||
fRange := rsCDATA;
|
||||
Inc(Run, 7);
|
||||
end else begin
|
||||
fTokenID := tkSymbol;
|
||||
fRange := rsElement;
|
||||
Inc(Run);
|
||||
end;
|
||||
end else if fLine[Run]= '?' then begin
|
||||
fTokenID := tkProcessingInstruction;
|
||||
fRange := rsProcessingInstruction;
|
||||
Inc(Run);
|
||||
end else begin
|
||||
fTokenID := tkSymbol;
|
||||
fRange := rsElement;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.GreaterThanProc;
|
||||
begin
|
||||
fTokenId := tkSymbol;
|
||||
fRange:= rsText;
|
||||
Inc(Run);
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.CommentProc;
|
||||
begin
|
||||
if (fLine[Run] = '-') and (fLine[Run + 1] = '-') and (fLine[Run + 2] = '>')
|
||||
then begin
|
||||
fTokenID := tkSymbol;
|
||||
fRange:= rsText;
|
||||
Inc(Run, 3);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
fTokenID := tkComment;
|
||||
|
||||
if (fLine[Run] In [#0, #10, #13]) then begin
|
||||
fProcTable[fLine[Run]]{$IFDEF FPC}(){$ENDIF};
|
||||
Exit;
|
||||
end;
|
||||
|
||||
while not (fLine[Run] in [#0, #10, #13]) do begin
|
||||
if (fLine[Run] = '-') and (fLine[Run + 1] = '-') and (fLine[Run + 2] = '>')
|
||||
then begin
|
||||
fRange := rsComment;
|
||||
break;
|
||||
end;
|
||||
Inc(Run);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.ProcessingInstructionProc;
|
||||
begin
|
||||
fTokenID := tkProcessingInstruction;
|
||||
if (fLine[Run] In [#0, #10, #13]) then begin
|
||||
fProcTable[fLine[Run]]{$IFDEF FPC}(){$ENDIF};
|
||||
Exit;
|
||||
end;
|
||||
|
||||
while not (fLine[Run] in [#0, #10, #13]) do begin
|
||||
if (fLine[Run] = '>') and (fLine[Run - 1] = '?')
|
||||
then begin
|
||||
fRange := rsText;
|
||||
Inc(Run);
|
||||
break;
|
||||
end;
|
||||
Inc(Run);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.DocTypeProc; //ek 2001-11-11
|
||||
begin
|
||||
fTokenID := tkDocType;
|
||||
|
||||
if (fLine[Run] In [#0, #10, #13]) then begin
|
||||
fProcTable[fLine[Run]]{$IFDEF FPC}(){$ENDIF};
|
||||
Exit;
|
||||
end;
|
||||
|
||||
case fRange of
|
||||
rsDocType:
|
||||
begin
|
||||
while not (fLine[Run] in [#0, #10, #13]) do
|
||||
begin
|
||||
case fLine[Run] of
|
||||
'[': begin
|
||||
while True do
|
||||
begin
|
||||
inc(Run);
|
||||
case fLine[Run] of
|
||||
']':
|
||||
begin
|
||||
Inc(Run);
|
||||
Exit;
|
||||
end;
|
||||
#0, #10, #13:
|
||||
begin
|
||||
fRange:=rsDocTypeSquareBraces;
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
'>': begin
|
||||
fRange := rsAttribute;
|
||||
Inc(Run);
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
inc(Run);
|
||||
end;
|
||||
end;
|
||||
rsDocTypeSquareBraces:
|
||||
begin
|
||||
while not (fLine[Run] in [#0, #10, #13]) do
|
||||
begin
|
||||
if (fLine[Run]=']') then
|
||||
begin
|
||||
fRange := rsDocType;
|
||||
Inc(Run);
|
||||
Exit;
|
||||
end;
|
||||
inc(Run);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.CDATAProc;
|
||||
begin
|
||||
fTokenID := tkCDATA;
|
||||
if (fLine[Run] In [#0, #10, #13]) then
|
||||
begin
|
||||
fProcTable[fLine[Run]]{$IFDEF FPC}(){$ENDIF};
|
||||
Exit;
|
||||
end;
|
||||
|
||||
while not (fLine[Run] in [#0, #10, #13]) do
|
||||
begin
|
||||
if (fLine[Run] = '>') and (fLine[Run - 1] = ']')
|
||||
then begin
|
||||
fRange := rsText;
|
||||
Inc(Run);
|
||||
break;
|
||||
end;
|
||||
Inc(Run);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.ElementProc;
|
||||
begin
|
||||
if fLine[Run] = '/' then Inc(Run);
|
||||
while (fLine[Run] in NameChars) do Inc(Run);
|
||||
fRange := rsAttribute;
|
||||
fTokenID := tkElement;
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.AttributeProc;
|
||||
begin
|
||||
//Check if we are starting on a closing quote
|
||||
if (fLine[Run] in [#34, #39]) then
|
||||
begin
|
||||
fTokenID := tkSymbol;
|
||||
fRange := rsAttribute;
|
||||
Inc(Run);
|
||||
Exit;
|
||||
end;
|
||||
//Read the name
|
||||
while (fLine[Run] in NameChars) do Inc(Run);
|
||||
//Check if this is an xmlns: attribute
|
||||
if (Pos('xmlns', GetToken) > 0) then begin
|
||||
fTokenID := tknsAttribute;
|
||||
fRange := rsnsEqual;
|
||||
end else begin
|
||||
fTokenID := tkAttribute;
|
||||
fRange := rsEqual;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.EqualProc;
|
||||
begin
|
||||
if fRange = rsnsEqual then
|
||||
fTokenID := tknsEqual
|
||||
else
|
||||
fTokenID := tkEqual;
|
||||
|
||||
while not (fLine[Run] in [#0, #10, #13]) do
|
||||
begin
|
||||
if (fLine[Run] = '/') then
|
||||
begin
|
||||
fTokenID := tkSymbol;
|
||||
fRange := rsElement;
|
||||
Inc(Run);
|
||||
Exit;
|
||||
end else if (fLine[Run] = #34) then
|
||||
begin
|
||||
if fRange = rsnsEqual then
|
||||
fRange := rsnsQuoteAttrValue
|
||||
else
|
||||
fRange := rsQuoteAttrValue;
|
||||
Inc(Run);
|
||||
Exit;
|
||||
end else if (fLine[Run] = #39) then
|
||||
begin
|
||||
if fRange = rsnsEqual then
|
||||
fRange := rsnsAPosAttrValue
|
||||
else
|
||||
fRange := rsAPosAttrValue;
|
||||
Inc(Run);
|
||||
Exit;
|
||||
end;
|
||||
Inc(Run);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.QAttributeValueProc;
|
||||
begin
|
||||
if fRange = rsnsQuoteAttrValue then
|
||||
fTokenID := tknsQuoteAttrValue
|
||||
else
|
||||
fTokenID := tkQuoteAttrValue;
|
||||
|
||||
while not (fLine[Run] in [#0, #10, #13, '&', #34]) do Inc(Run);
|
||||
|
||||
if fLine[Run] = '&' then
|
||||
begin
|
||||
if fRange = rsnsQuoteAttrValue then
|
||||
fRange := rsnsQuoteEntityRef
|
||||
else
|
||||
fRange := rsQuoteEntityRef;
|
||||
Exit;
|
||||
end else if fLine[Run] <> #34 then
|
||||
begin
|
||||
Exit;
|
||||
end;
|
||||
|
||||
fRange := rsAttribute;
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.AAttributeValueProc;
|
||||
begin
|
||||
if fRange = rsnsAPosAttrValue then
|
||||
fTokenID := tknsAPosAttrValue
|
||||
else
|
||||
fTokenID := tkAPosAttrValue;
|
||||
|
||||
while not (fLine[Run] in [#0, #10, #13, '&', #39]) do Inc(Run);
|
||||
|
||||
if fLine[Run] = '&' then
|
||||
begin
|
||||
if fRange = rsnsAPosAttrValue then
|
||||
fRange := rsnsAPosEntityRef
|
||||
else
|
||||
fRange := rsAPosEntityRef;
|
||||
Exit;
|
||||
end else if fLine[Run] <> #39 then
|
||||
begin
|
||||
Exit;
|
||||
end;
|
||||
|
||||
fRange := rsAttribute;
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.TextProc;
|
||||
const StopSet = [#0..#31, '<', '&'];
|
||||
begin
|
||||
if fLine[Run] in (StopSet - ['&']) then begin
|
||||
fProcTable[fLine[Run]]{$IFDEF FPC}(){$ENDIF};
|
||||
exit;
|
||||
end;
|
||||
|
||||
fTokenID := tkText;
|
||||
while not (fLine[Run] in StopSet) do Inc(Run);
|
||||
|
||||
if (fLine[Run] = '&') then begin
|
||||
fRange := rsEntityRef;
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.EntityRefProc;
|
||||
begin
|
||||
fTokenID := tkEntityRef;
|
||||
fRange := rsEntityRef;
|
||||
while not (fLine[Run] in [#0..#32, ';']) do Inc(Run);
|
||||
if (fLine[Run] = ';') then Inc(Run);
|
||||
fRange := rsText;
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.QEntityRefProc;
|
||||
begin
|
||||
if fRange = rsnsQuoteEntityRef then
|
||||
fTokenID := tknsQuoteEntityRef
|
||||
else
|
||||
fTokenID := tkQuoteEntityRef;
|
||||
|
||||
while not (fLine[Run] in [#0..#32, ';']) do Inc(Run);
|
||||
if (fLine[Run] = ';') then Inc(Run);
|
||||
|
||||
if fRange = rsnsQuoteEntityRef then
|
||||
fRange := rsnsQuoteAttrValue
|
||||
else
|
||||
fRange := rsQuoteAttrValue;
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.AEntityRefProc;
|
||||
begin
|
||||
if fRange = rsnsAPosEntityRef then
|
||||
fTokenID := tknsAPosEntityRef
|
||||
else
|
||||
fTokenID := tkAPosEntityRef;
|
||||
|
||||
while not (fLine[Run] in [#0..#32, ';']) do Inc(Run);
|
||||
if (fLine[Run] = ';') then Inc(Run);
|
||||
|
||||
if fRange = rsnsAPosEntityRef then
|
||||
fRange := rsnsAPosAttrValue
|
||||
else
|
||||
fRange := rsAPosAttrValue;
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.IdentProc;
|
||||
begin
|
||||
case fRange of
|
||||
rsElement:
|
||||
begin
|
||||
ElementProc{$IFDEF FPC}(){$ENDIF};
|
||||
end;
|
||||
rsAttribute:
|
||||
begin
|
||||
AttributeProc{$IFDEF FPC}(){$ENDIF};
|
||||
end;
|
||||
rsEqual, rsnsEqual:
|
||||
begin
|
||||
EqualProc{$IFDEF FPC}(){$ENDIF};
|
||||
end;
|
||||
rsQuoteAttrValue, rsnsQuoteAttrValue:
|
||||
begin
|
||||
QAttributeValueProc{$IFDEF FPC}(){$ENDIF};
|
||||
end;
|
||||
rsAposAttrValue, rsnsAPosAttrValue:
|
||||
begin
|
||||
AAttributeValueProc{$IFDEF FPC}(){$ENDIF};
|
||||
end;
|
||||
rsQuoteEntityRef, rsnsQuoteEntityRef:
|
||||
begin
|
||||
QEntityRefProc{$IFDEF FPC}(){$ENDIF};
|
||||
end;
|
||||
rsAposEntityRef, rsnsAPosEntityRef:
|
||||
begin
|
||||
AEntityRefProc{$IFDEF FPC}(){$ENDIF};
|
||||
end;
|
||||
rsEntityRef:
|
||||
begin
|
||||
EntityRefProc{$IFDEF FPC}(){$ENDIF};
|
||||
end;
|
||||
else ;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.Next;
|
||||
begin
|
||||
fTokenPos := Run;
|
||||
case fRange of
|
||||
rsText:
|
||||
begin
|
||||
TextProc{$IFDEF FPC}(){$ENDIF};
|
||||
end;
|
||||
rsComment:
|
||||
begin
|
||||
CommentProc{$IFDEF FPC}(){$ENDIF};
|
||||
end;
|
||||
rsProcessingInstruction:
|
||||
begin
|
||||
ProcessingInstructionProc{$IFDEF FPC}(){$ENDIF};
|
||||
end;
|
||||
rsDocType, rsDocTypeSquareBraces: //ek 2001-11-11
|
||||
begin
|
||||
DocTypeProc{$IFDEF FPC}(){$ENDIF};
|
||||
end;
|
||||
rsCDATA:
|
||||
begin
|
||||
CDATAProc{$IFDEF FPC}(){$ENDIF};
|
||||
end;
|
||||
else
|
||||
fProcTable[fLine[Run]]{$IFDEF FPC}(){$ENDIF};
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSynXMLSyn.NextTokenIs(T : String) : Boolean;
|
||||
var I, Len : Integer;
|
||||
begin
|
||||
Result:= True;
|
||||
Len:= Length(T);
|
||||
for I:= 1 to Len do
|
||||
if (fLine[Run + I] <> T[I]) then
|
||||
begin
|
||||
Result:= False;
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSynXMLSyn.GetDefaultAttribute(
|
||||
Index: integer): TSynHighlighterAttributes;
|
||||
begin
|
||||
case Index of
|
||||
SYN_ATTR_COMMENT: Result := fCommentAttri;
|
||||
SYN_ATTR_IDENTIFIER: Result := fAttributeAttri;
|
||||
SYN_ATTR_KEYWORD: Result := fElementAttri;
|
||||
SYN_ATTR_WHITESPACE: Result := fSpaceAttri;
|
||||
SYN_ATTR_SYMBOL: Result := fSymbolAttri;
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSynXMLSyn.GetEol: Boolean;
|
||||
begin
|
||||
Result := fTokenId = tkNull;
|
||||
end;
|
||||
|
||||
function TSynXMLSyn.GetToken: string;
|
||||
var
|
||||
len: Longint;
|
||||
begin
|
||||
Len := (Run - fTokenPos);
|
||||
SetString(Result, (FLine + fTokenPos), len);
|
||||
end;
|
||||
|
||||
function TSynXMLSyn.GetTokenID: TtkTokenKind;
|
||||
begin
|
||||
Result := fTokenId;
|
||||
end;
|
||||
|
||||
function TSynXMLSyn.GetTokenAttribute: TSynHighlighterAttributes;
|
||||
begin
|
||||
case fTokenID of
|
||||
tkElement: Result:= fElementAttri;
|
||||
tkAttribute: Result:= fAttributeAttri;
|
||||
tknsAttribute: Result:= fnsAttributeAttri;
|
||||
tkEqual: Result:= fSymbolAttri;
|
||||
tknsEqual: Result:= fSymbolAttri;
|
||||
tkQuoteAttrValue: Result:= fAttributeValueAttri;
|
||||
tkAPosAttrValue: Result:= fAttributeValueAttri;
|
||||
tknsQuoteAttrValue: Result:= fnsAttributeValueAttri;
|
||||
tknsAPosAttrValue: Result:= fnsAttributeValueAttri;
|
||||
tkText: Result:= fTextAttri;
|
||||
tkCDATA: Result:= fCDATAAttri;
|
||||
tkEntityRef: Result:= fEntityRefAttri;
|
||||
tkQuoteEntityRef: Result:= fEntityRefAttri;
|
||||
tkAposEntityRef: Result:= fEntityRefAttri;
|
||||
tknsQuoteEntityRef: Result:= fEntityRefAttri;
|
||||
tknsAposEntityRef: Result:= fEntityRefAttri;
|
||||
tkProcessingInstruction: Result:= fProcessingInstructionAttri;
|
||||
tkComment: Result:= fCommentAttri;
|
||||
tkDocType: Result:= fDocTypeAttri;
|
||||
tkSymbol: Result:= fSymbolAttri;
|
||||
tkSpace: Result:= fSpaceAttri;
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSynXMLSyn.GetTokenKind: integer;
|
||||
begin
|
||||
Result := Ord(fTokenId);
|
||||
end;
|
||||
|
||||
function TSynXMLSyn.GetTokenPos: Integer;
|
||||
begin
|
||||
Result := fTokenPos;
|
||||
end;
|
||||
|
||||
function TSynXMLSyn.GetRange: Pointer;
|
||||
begin
|
||||
Result := Pointer(fRange);
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.SetRange(Value: Pointer);
|
||||
begin
|
||||
fRange := TRangeState(Value);
|
||||
end;
|
||||
|
||||
procedure TSynXMLSyn.ReSetRange;
|
||||
begin
|
||||
fRange:= rsText;
|
||||
end;
|
||||
|
||||
function TSynXMLSyn.GetIdentChars: TSynIdentChars;
|
||||
begin
|
||||
Result := ['0'..'9', 'a'..'z', 'A'..'Z', '_', '.', '-'] + TSynSpecialChars;
|
||||
end;
|
||||
|
||||
{$IFNDEF SYN_CPPB_1} class {$ENDIF}
|
||||
function TSynXMLSyn.GetLanguageName: string;
|
||||
begin
|
||||
Result := SYNS_LangXML;
|
||||
end;
|
||||
|
||||
function TSynXMLSyn.GetSampleSource: String;
|
||||
begin
|
||||
Result:= '<?xml version="1.0"?>'#13#10+
|
||||
'<!DOCTYPE root ['#13#10+
|
||||
' ]>'#13#10+
|
||||
'<!-- Comment -->'#13#10+
|
||||
'<root version="&test;">'#13#10+
|
||||
' <![CDATA[ **CDATA section** ]]>'#13#10+
|
||||
'</root>';
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
||||
{$IFNDEF SYN_CPPB_1}
|
||||
RegisterPlaceableHighlighter(TSynXMLSyn);
|
||||
{$ENDIF}
|
||||
|
||||
end.
|
||||
|
||||
|
||||
|
@ -29,7 +29,8 @@ uses
|
||||
FileCtrl, Graphics, Controls, Dialogs, LResources,
|
||||
{$ifdef NEW_EDITOR_SYNEDIT}
|
||||
SynEdit, SynEditHighlighter, SynEditAutoComplete, SynEditKeyCmds,
|
||||
SynHighlighterPas, SynHighlighterHTML, SynHighlighterCPP,
|
||||
SynHighlighterPas, SynHighlighterHTML, SynHighlighterCPP, SynHighlighterXML,
|
||||
SynHighlighterLFM,
|
||||
{$else}
|
||||
mwCustomEdit, mwPasSyn, mwHighlighter,
|
||||
{$endif}
|
||||
@ -69,7 +70,8 @@ const
|
||||
);
|
||||
|
||||
LazSyntaxHighlighterClasses: array[TLazSyntaxHighlighter] of TCustomSynClass =
|
||||
( nil, nil, TSynPasSyn, TSynPasSyn, nil, nil, TSynHTMLSyn, TSynCPPSyn);
|
||||
( nil, nil, TSynPasSyn, TSynPasSyn, TSynLFMSyn, TSynXMLSyn, TSynHTMLSyn,
|
||||
TSynCPPSyn);
|
||||
|
||||
type
|
||||
{ TEditOptLanguageInfo stores lazarus IDE additional information
|
||||
@ -754,7 +756,7 @@ begin
|
||||
with NewInfo do begin
|
||||
TheType:=CompatibleLazSyntaxHilighter[lshCPP];
|
||||
SynClass:=LazSyntaxHighlighterClasses[TheType];
|
||||
FileExtensions:='c;cc;cpp;h';
|
||||
FileExtensions:='c;cc;cpp;h;hpp';
|
||||
SampleSource:=
|
||||
'/* Comment */'#13+
|
||||
'#include <stdio.h>'#13+
|
||||
@ -785,6 +787,66 @@ begin
|
||||
end;
|
||||
end;
|
||||
Add(NewInfo);
|
||||
|
||||
// create info for XML
|
||||
NewInfo:=TEditOptLanguageInfo.Create;
|
||||
with NewInfo do begin
|
||||
TheType:=CompatibleLazSyntaxHilighter[lshXML];
|
||||
SynClass:=LazSyntaxHighlighterClasses[TheType];
|
||||
FileExtensions:='xml;xsd;xsl;xslt;dtd';
|
||||
SampleSource:=
|
||||
'<?xml version="1.0"?>'#13+
|
||||
'<!DOCTYPE root ['#13+
|
||||
' ]>'#13+
|
||||
'<!-- Comment -->'#13+
|
||||
'<root version="&test;">'#13+
|
||||
' <![CDATA[ **CDATA section** ]]>'#13+
|
||||
'</root>'#13+
|
||||
'<!-- Text Block -->'#13+
|
||||
''#13+
|
||||
#13;
|
||||
AddAttrSampleLines[ahaTextBlock]:=8;
|
||||
MappedAttributes:=TStringList.Create;
|
||||
with MappedAttributes do begin
|
||||
Add('Element=Reserved_word');
|
||||
Add('Comment=Comment');
|
||||
Add('Text=Identifier');
|
||||
Add('Space=Space');
|
||||
Add('Symbol=Symbol');
|
||||
end;
|
||||
end;
|
||||
Add(NewInfo);
|
||||
|
||||
// create info for LFM
|
||||
NewInfo:=TEditOptLanguageInfo.Create;
|
||||
with NewInfo do begin
|
||||
TheType:=CompatibleLazSyntaxHilighter[lshLFM];
|
||||
SynClass:=LazSyntaxHighlighterClasses[TheType];
|
||||
FileExtensions:='lfm;dfm;xfm';
|
||||
SampleSource:=
|
||||
'{ Lazarus Form Definitions }'#13+
|
||||
'object TestForm: TTestForm'#13+
|
||||
' Left = 273'#13+
|
||||
' Top = 103'#13+
|
||||
' Caption = ''sample source'''#13+
|
||||
'end'#13+
|
||||
'{ Text Block }'#13+
|
||||
''#13+
|
||||
#13;
|
||||
AddAttrSampleLines[ahaTextBlock]:=7;
|
||||
MappedAttributes:=TStringList.Create;
|
||||
with MappedAttributes do begin
|
||||
Add('Element=Reserved_word');
|
||||
Add('Comment=Comment');
|
||||
Add('Identifier=Identifier');
|
||||
Add('Key=Reserved_word');
|
||||
Add('Number=Number');
|
||||
Add('Space=Space');
|
||||
Add('String=String');
|
||||
Add('Symbol=Symbol');
|
||||
end;
|
||||
end;
|
||||
Add(NewInfo);
|
||||
end;
|
||||
|
||||
destructor TEditOptLangList.Destroy;
|
||||
@ -1660,7 +1722,7 @@ begin
|
||||
FormCreating:=true;
|
||||
|
||||
if LazarusResources.Find(ClassName)=nil then begin
|
||||
SetBounds((Screen.Width-470) div 2,(Screen.Height-480) div 2, 455,459);
|
||||
SetBounds((Screen.Width-490) div 2,(Screen.Height-480) div 2, 480,459);
|
||||
Caption:='Editor Options';
|
||||
SynAutoComplete:=TSynEditAutoComplete.Create(Self);
|
||||
|
||||
@ -2708,7 +2770,7 @@ end;
|
||||
procedure TEditorOptionsForm.SetupGeneralPage;
|
||||
var MaxX,ChkBoxW:integer;
|
||||
begin
|
||||
MaxX:=Width-9;
|
||||
MaxX:=Width-5;
|
||||
ChkBoxW:=(MaxX-20) div 2;
|
||||
|
||||
EditorOptionsGroupBox:=TGroupBox.Create(Self);
|
||||
@ -3105,7 +3167,7 @@ end;
|
||||
procedure TEditorOptionsForm.SetupDisplayPage;
|
||||
var MaxX,MaxY,ChkBoxW:integer;
|
||||
begin
|
||||
MaxX:=Width-9;
|
||||
MaxX:=Width-5;
|
||||
MaxY:=375;
|
||||
ChkBoxW:=140;
|
||||
|
||||
@ -3479,16 +3541,16 @@ end;
|
||||
procedure TEditorOptionsForm.SetupColorPage;
|
||||
var a,MaxX,MaxY:integer;
|
||||
begin
|
||||
MaxX:=Width-9;
|
||||
MaxY:=375;
|
||||
MaxX:=Width-5;
|
||||
MaxY:=377;
|
||||
|
||||
LanguageComboBox:=TComboBox.Create(Self);
|
||||
with LanguageComboBox do begin
|
||||
Name:='LanguageComboBox';
|
||||
Parent:=MainNoteBook.Page[3];
|
||||
Top:=5;
|
||||
Left:=80;
|
||||
Width:=130;
|
||||
Left:=75;
|
||||
Width:=170;
|
||||
Height:=20;
|
||||
with Items do begin
|
||||
BeginUpdate;
|
||||
@ -3520,7 +3582,7 @@ begin
|
||||
Name:='ColorSchemeComboBox';
|
||||
Parent:=MainNoteBook.Page[3];
|
||||
Top:=LanguageComboBox.Top;
|
||||
Left:=LanguageComboBox.Left+LanguageComboBox.Width+120;
|
||||
Left:=LanguageComboBox.Left+LanguageComboBox.Width+110;
|
||||
Width:=100;
|
||||
Height:=20;
|
||||
with Items do begin
|
||||
@ -3554,7 +3616,7 @@ begin
|
||||
Name:='FileExtensionsComboBox';
|
||||
Parent:=MainNoteBook.Page[3];
|
||||
Top:=ColorSchemeComboBox.Top+ColorSchemeComboBox.Height+4;
|
||||
Left:=110;
|
||||
Left:=103;
|
||||
Width:=310;
|
||||
Height:=20;
|
||||
Items.BeginUpdate;
|
||||
@ -3588,7 +3650,7 @@ begin
|
||||
Parent:=MainNoteBook.Page[3];
|
||||
Top:=FileExtensionsComboBox.Top+FileExtensionsComboBox.Height+12;
|
||||
Left:=5;
|
||||
Width:=150;
|
||||
Width:=180;
|
||||
Height:=16;
|
||||
Caption:='Element';
|
||||
Visible:=true;
|
||||
@ -3781,7 +3843,7 @@ end;
|
||||
procedure TEditorOptionsForm.SetupCodeToolsPage;
|
||||
var MaxX:integer;
|
||||
begin
|
||||
MaxX:=Width-9;
|
||||
MaxX:=Width-5;
|
||||
|
||||
AutomaticFeaturesGroupBox:=TGroupBox.Create(Self);
|
||||
with AutomaticFeaturesGroupBox do begin
|
||||
@ -3799,9 +3861,10 @@ begin
|
||||
with AutoCodeCompletionCheckBox do begin
|
||||
Name:='AutoCodeCompletionCheckBox';
|
||||
Parent:=AutomaticFeaturesGroupBox;
|
||||
Top:=5;
|
||||
Top:=2;
|
||||
Left:=5;
|
||||
Width:=200;
|
||||
Height:=20;
|
||||
Caption:='Code completion';
|
||||
Checked:=EditorOpts.AutoCodeCompletion;
|
||||
Enabled:=false;
|
||||
@ -3812,7 +3875,7 @@ begin
|
||||
with AutoCodeParametersCheckBox do begin
|
||||
Name:='AutoCodeParametersCheckBox';
|
||||
Parent:=AutomaticFeaturesGroupBox;
|
||||
Top:=AutoCodeCompletionCheckBox.Top+AutoCodeCompletionCheckBox.Height+20;
|
||||
Top:=AutoCodeCompletionCheckBox.Top+AutoCodeCompletionCheckBox.Height;
|
||||
Left:=AutoCodeCompletionCheckBox.Left;
|
||||
Width:=AutoCodeCompletionCheckBox.Width;
|
||||
Height:=AutoCodeCompletionCheckBox.Height;
|
||||
@ -3826,7 +3889,7 @@ begin
|
||||
with AutoToolTipExprEvalCheckBox do begin
|
||||
Name:='AutoToolTipExprEvalCheckBox';
|
||||
Parent:=AutomaticFeaturesGroupBox;
|
||||
Top:=AutoCodeParametersCheckBox.Top+AutoCodeParametersCheckBox.Height+20;
|
||||
Top:=AutoCodeParametersCheckBox.Top+AutoCodeParametersCheckBox.Height;
|
||||
Left:=AutoCodeCompletionCheckBox.Left;
|
||||
Width:=AutoCodeCompletionCheckBox.Width;
|
||||
Height:=AutoCodeCompletionCheckBox.Height;
|
||||
@ -3840,7 +3903,7 @@ begin
|
||||
with AutoToolTipSymbToolsCheckBox do begin
|
||||
Name:='AutoToolTipSymbToolsCheckBox';
|
||||
Parent:=AutomaticFeaturesGroupBox;
|
||||
Top:=AutoToolTipExprEvalCheckBox.Top+AutoToolTipExprEvalCheckBox.Height+20;
|
||||
Top:=AutoToolTipExprEvalCheckBox.Top+AutoToolTipExprEvalCheckBox.Height;
|
||||
Left:=AutoCodeCompletionCheckBox.Left;
|
||||
Width:=AutoCodeCompletionCheckBox.Width;
|
||||
Height:=AutoCodeCompletionCheckBox.Height;
|
||||
|
Loading…
Reference in New Issue
Block a user